@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

 

posted @ 2019-08-02 16:03  花花牛  阅读(4009)  评论(0编辑  收藏  举报