@ImportResource加载spring.xml配置文件

springboot 默认不需要xxx.xml配置文件,即使加上配置文件,也不能自动识别

需要在主启动类的类名加上@ImportResource注解:

@ImportResource(location={"classpath:xxx.xml"})
@SpringBootApplication //该注解标准主启动类
public class Main {
    public static void main(String[] args) {
        SpringApplication.run(Main.class,args);
    }
}

原文出处:/show_1EF5rAerbJ5o.html