經常使用@PropertySource 來指定配置文件,然后@value獲取配置參數:
1 @Component 2 @PropertySource(value= {"classpath:rules.yml"}) 3 @ConfigurationProperties(prefix = "busi-udid-mapper")
默認,配置文件都是指定classpath下的文件路徑,如果使用絕對路徑(操作系統下某個配置文件路徑),請使用如下方式:
1 @Component 2 @PropertySource(value= {"file:${rule.fullpath}"}) 3 @ConfigurationProperties(prefix = "busi-udid-mapper")
這里的rule.funnpath是在系統配置文件中變量化的參數
參考:
http://www.voidcn.com/article/p-scladotq-bva.html