SpringBoot注解ImportResource的使用
SpringBoot提倡构建零配置文件项目,但当需引入其他配置文件时可以在SpringBoot启动类上加@ImportResource注解,即可将该引入注解加载到SpringBoot容器中。
@SpringBootApplication
@ImportResource(locations={"classpath:文件"})
public class SpringBootConfigApplication {
public static void main(String[] args) {
SpringApplication.run(SpringBootConfigApplication.class, args);
}
在这里要注意classpath所指文件