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

1、@PropertySource

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

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

2、@ImportResource

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

详细见 => click here

3、@Bean

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

扫描二维码关注公众号,回复: 9601961 查看本文章

猜你喜欢

转载自www.cnblogs.com/qwertiLH/p/12203068.html