@PropertySource和@ImportSource

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

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

 

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

 

spring boot里面没有spring的配置文件,我们自己编写的配置文件,也不能自动识别,想让spring的配置文件生效,加载进来。用@ImportSource标注在一个配置类上

  @ImportSource(locations = {"classpath:bean.xml"})

 

Spring Boot推荐给容器中添加组件的方式

1、配置类---spring配置文件

2、使用@bean给容器添加组件

 

 

posted @ 2019-02-15 18:17  被爱的都有恃无恐  阅读(503)  评论(0编辑  收藏  举报