SpringBoot —— @ImportResource

用法

在启动类上增加@ImportResource注解,引入对应配置文件。

如果不使用@ImportResource()注解,程序根本不能对我们spring的配置文件进行加载,所以我们需要将spring配置文件加载到容器里。

示例

@ImportResource({"classpath:xxx.xml"})
public class XXXApplication {
    public static void main(String[] args) {
        SpringApplication.run(XXXApplication.class, args);
    }
}

猜你喜欢

转载自blog.csdn.net/xue_xiaofei/article/details/110172055