首页 > 数据库技术 > 详细

springboot中@PropertySource(value = {"classpath:FoundBean.properties"})读取不出内容

时间:2020-07-14 14:11:51      阅读:253      评论:0      收藏:0      [点我收藏+]

 情景:因为不可能所有的属性都放在全局文件(SpringBoot项目使用一个全局的配置文件application.properties或者是application.yml)中

所以需要把一些跟springboot无关的东西放在其他文件,用 @PropertySource:加载指定的配置文件;
直接用@PropertySource读取不到值,原因在于@PropertySource需要和@propertyConfiguration一起使用
@Component
@ConfigurationProperties(prefix = "person")

最终要注解内容有:

@Component
@ConfigurationProperties(prefix = "person")
@PropertySource(value={"classpath:/person.properties"})


详情链接

springboot中@PropertySource(value = {"classpath:FoundBean.properties"})读取不出内容

原文:https://www.cnblogs.com/asplover/p/13298350.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!