@PropertySource絕對路徑(java.io.FileNotFoundException問題解決)


經常使用@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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM