@PropertySource @ImportResource @Bean

@PropertySource

1,为使用要使用@PropertySource

所有的配置都是写在 appliaction.properties application.yml 文件里,

那么如果不想写在这里面怎么处理呢使用 @PropertySource 可以解决

2,注入优先级的问题

所在的配置都是优先注入 appliaction.properties application.yml 里面的数据

如果要不一样,必须修改配置文件引入的前缀

@PropertySource @ImportResource @Bean



@ImportResource

1,为什么要使用@ImportResource

从上面所有的配置中可以看出我们没有使用以前的 spring 的 xml 的配置方法,如果还是要使用 spring 里面的 xml 的配置方式怎么办理,使用@ImportResource

@PropertySource @ImportResource @Bean

 

@PropertySource @ImportResource @Bean

@PropertySource @ImportResource @Bean



@PropertySource @ImportResource @Bean