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
 

猜你喜欢

转载自blog.csdn.net/weixin_49723367/article/details/115011276
今日推荐