Spring Boot 1.5+ 加载自定义yml配置文件
引言
Spring Boot 1.5之前读取配置文件使用ConfigurationProperties以及PropertySource注解很好用,但是在使用1.5之后,你会发现ConfigurationProperties中location没用了,而使用PropertySource也不能读取yml文件,官方原话:
PropertySourcesPlaceholderConfigurer 加载
在启动类里注入一个Bean,用于加载自定义 yml配置文件
/**
* 加载yml配置文件,根目录为resources
* @return
*/
@Bean
public static PropertySourcesPlaceholderConfigurer properties() {