spring注入properties文件的can not resolve placeholder问题
2017-08-24 18:09
1036 查看
一般有三种情况:
(1)location中的属性文件配置错误
(2)location中定义的配置文件里面没有对应的placeholder值
(3)可能是Spring容器的配置问题
前两种注意查看拼写,路径基本都能解决,第三种在查阅相关资料后应按如下的方式解决:
Spring容器采用反射扫描的发现机制,在探测到Spring容器中有一个org.springframework.beans.factory.config.PropertyPlaceholderConfigurer的Bean就会停止对剩余PropertyPlaceholderConfigurer的扫描(Spring 3.1已经使用PropertySourcesPlaceholderConfigurer替代PropertyPlaceholderConfigurer了)。
而这个基于命名空间的配置,其实内部就是创建一个PropertyPlaceholderConfigurer Bean而已。换句话说,即Spring容器仅允许最多定义一个PropertyPlaceholderConfigurer(或),其余的会被Spring忽略掉(其实Spring如果提供一个警告就好了)。
(参考:http://blog.sina.com.cn/s/blog_5a15b7d10102w4k2.html)
所以在所有<context:property-placeholder/>标签添加ignore-unresolvable="true"
(1)location中的属性文件配置错误
(2)location中定义的配置文件里面没有对应的placeholder值
(3)可能是Spring容器的配置问题
前两种注意查看拼写,路径基本都能解决,第三种在查阅相关资料后应按如下的方式解决:
Spring容器采用反射扫描的发现机制,在探测到Spring容器中有一个org.springframework.beans.factory.config.PropertyPlaceholderConfigurer的Bean就会停止对剩余PropertyPlaceholderConfigurer的扫描(Spring 3.1已经使用PropertySourcesPlaceholderConfigurer替代PropertyPlaceholderConfigurer了)。
而这个基于命名空间的配置,其实内部就是创建一个PropertyPlaceholderConfigurer Bean而已。换句话说,即Spring容器仅允许最多定义一个PropertyPlaceholderConfigurer(或),其余的会被Spring忽略掉(其实Spring如果提供一个警告就好了)。
(参考:http://blog.sina.com.cn/s/blog_5a15b7d10102w4k2.html)
所以在所有<context:property-placeholder/>标签添加ignore-unresolvable="true"
相关文章推荐
- spring加载多个properties文件出现 Could not resolve placeholder
- IntelliJIdea 10.5.2 解决jsp文件提示can not resolve...问题
- Spring代码实例系列-09:通过Spring PropertyPlaceholderConfigurer将properties配置的属性注入到xml配置文件中
- spring boot could not resolve placeholder in string value 问题解决方法
- Spring 中注入bean的properties配置文件位置问题解决
- Spring 出现Could not resolve placeholder问题的解决方法
- Spring 中注入bean的properties配置文件位置问题解决
- spring加载properities文件的时候的报错Could not resolve placeholder
- [置顶] android studio 查看源码时有些类显示 can not resolve 的问题
- spring错误<context:property-placeholder>:Could not resolve placeholder XXX in string value XXX
- Spring配置文件context:property-placeholder无法载入属性问题
- Spring中报"Could not resolve placeholder"的解决方案
- 基于maven管理的项目中spring+mybatis配置数据源读取不到properties属性文件的问题
- spring List,Set,Map,Properties,array的使用配置文件注入实例
- 遇到问题----struts2文件下载出现Can not find a java.io.InputStream with the name的错误
- java.io.FileNotFoundException问题,说是db.properties文件找
- mybatis3.0x升级整合spring问题(读取不到properties文件属性)
- java.io.FileNotFoundException问题,说是db.properties文件找不到,但是在webapps里存在的
- Spring PropertyPlaceholderConfigurer解析Java Properties属性文件值
- 遇到问题----struts2文件下载出现Can not find a java.io.InputStream with the name的错误