Spring Boot 学习笔记(四)@PropertySource、@ImportResource、@Bean

1、@PropertySource

@ConfigurationProperties 注解给Bean注入数据只能加载全局配置文件下的配置内容、若要单独指定另外的配置文件则需要用到@PropertySource

同时注意 @PropertySource 只支持 properties 文件上

 

2、@ImportResource

这个注解的作用是用来引入 spring 配置文件的,Boot中原本没有 spring 的配置文件,若要引入,则需要这个注解

详细见 => click here

 

3、@Bean

首先 springboot 并不推荐使用配置文件的方式来配置 Bean 对象,而是采用配置类的方式

posted @ 2020-03-05 18:00  qwerity  阅读(108)  评论(0编辑  收藏  举报