经常使用@PropertySource 来指定配置文件,然后@value获取配置参数:
@Component
@PropertySource(value= {"classpath:rules.yml"})
@ConfigurationProperties(prefix = "busi-udid-mapper")
默认,配置文件都是指定classpath下的文件路径,如果使用绝对路径(操作系统下某个配置文件路径),请使用如下方式:
@Component
@PropertySource(value= {"file:${rule.fullpath}"})
@ConfigurationProperties(prefix = "busi-udid-mapper")
这里的rule.funnpath是在系统配置文件中变量化的参数
参考: