Context initialization failed (上下文初始化失败 ) @Value(“${xxx}“) Could not resolve placeholder(无法解析占位符)

17:15:56,387 ERROR ContextLoader:316 - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'setmealServiceImpl': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'out_put_path' in value "${out_put_path}"
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues

当使用@Value时无法解析占位符,原因是我有两个spring.xml文件第一个文件导入了jdbc.properties,第二个Spring.xml有导入了freemarker.properties ,两个context:property-placeholder

冲突导致得。

 

解决方法:

删除其中一个context:property-placeholder ,只保留一个context:property-placeholder解决代码如下

<context:property-placeholder location="classpath:*.properties"/>

参考:

https://blog.csdn.net/zezezuiaiya/article/details/79172865?ops_request_misc=&request_id=&biz_id=102&utm_term=spring%E4%B8%AD@value%E4%B8%AD%E5%BE%97%E5%80%BC$%7B%7D%E4%B8%8D%E8%83%BD%E8%A7%A3%E6%9E%90&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-0-79172865.first_rank_v2_pc_rank_v29
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值