springboot中的配置的注解:@PropertySource和ImportResource

1、@PropertySource:加载指定的配置文件

  @PropertySource(value = {classpath:person.properties})

2、@ImportResource:导入Spring的配置文件,让配置文件里面的内容生效

  Spring Boot里面没有Spring的配置文件,我们自己编写的配置文件,也不能自动识别;

  想让Spring的配置文件生效,加载进来;@ImportResource标注在一个配置类上

  @ImportResource(locations = {"classpath:beans.xml"})

3、SpringBoot添加组件的方式

 

 

posted @ 2020-06-26 00:27  King-DA  阅读(180)  评论(0编辑  收藏  举报