spring Could not resolve placeholder
来源:互联网 发布:新疆继续教育网络培训 编辑:程序博客网 时间:2024/06/05 09:43
用spring 配置加载properties文件的时候,报
Could not resolve placeholder 错误。
经过仔细查找,排除文件路径,文件类容错误的原因,经过查找相关资料,出现"Could not resolve placeholder"很有可能是使用了多个PropertyPlaceholderConfigurer或者多个<context:property-placeholder>的原因或者是多个PropertyPlaceholderConfigurer与<context:property-placeholder>混合使用。
如果配置如下一定会报以上错误,不管是在多个配置文件中还是分别在不同文件中
- <context:property-placeholder location="WEB-INF/config/db/XX.properties" />
- <context:property-placeholder location="WEB-INF/config/dfs/XX.properties" />
解决方案:
在Spring3中可以用如下方式解决,增加ignore-unresolvable="true"属性,注意必须都要加上
在Spring3中可以用如下方式解决,增加ignore-unresolvable="true"属性,注意必须都要加上
- <context:property-placeholder location="xxx.properties" ignore-unresolvable="true" />
- <context:property-placeholder location="yyy.properties" ignore-unresolvable="true"
- />
- <bean id="XX" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
- <property name="location" value="xxx.properties" />
- <property name="ignoreUnresolvablePlaceholders" value="true" />
- </bean>
系统中如果报如上错误,可以这样查找:搜索系统中所有包含property-placeholder的文件,看是否包含ignore-unresolvable属性,然后搜索系统中所有包含PropertyPlaceholderConfigurer文件,看是否包含ignoreUnresolvablePlaceholders属性。
今天系统中报如上错误,就是因为按照PropertyPlaceholderConfigurer方式没有配置ignoreUnresolvablePlaceholders属性,而按照context:property-placeholder方式配置的都包含了ignore-unresolvable属性。
Spring容器采用反射扫描的发现机制,在探测到Spring容器中有一个org.springframework.beans.factory.config.PropertyPlaceholderConfigurer的Bean
就会停止对剩余PropertyPlaceholderConfigurer的扫描(Spring 3.1已经使用PropertySourcesPlaceholderConfigurer替代PropertyPlaceholderConfigurer了)。
而<context:property-placeholder/>这个基于命名空间的配置,其实内部就是创建一个PropertyPlaceholderConfigurer Bean而已。换句话说,即Spring容器仅允许最多定义一个PropertyPlaceholderConfigurer(或<context:property-placeholder/>),其余的会被Spring忽略掉(其实Spring如果提供一个警告就好了)。
0 0
- spring Could not resolve placeholder
- spring报“Could not resolve placeholder”错误
- spring报“Could not resolve placeholder”错误
- spring报“Could not resolve placeholder”错误
- spring报“Could not resolve placeholder”错误
- Could not resolve placeholder
- Could not resolve placeholder
- spring错误 Could not resolve Spring property placeholder
- "Could not resolve placeholder"解决方案
- Could not resolve placeholder 参考
- "Could not resolve placeholder"解决方案
- Could not resolve placeholder 解决方案
- Spring中报"Could not resolve placeholder"的解决方案
- Spring中报"Could not resolve placeholder"的解决方案
- Spring中报"Could not resolve placeholder"的解决方案
- spring报“Could not resolve placeholder”错误,解决方案
- spring报“Could not resolve placeholder”错误,解决方案
- Spring中报"Could not resolve placeholder"的解决方案
- 计算ScrollView控件的滑动距离
- C++ Primer Plus 第10章 对象和类
- GCC单独编译host/examples/ tx_waveforms.cpp
- Rabbit mq订阅方式获取消息并可设置持久化
- SylixOS系统简介
- spring Could not resolve placeholder
- iOS6中的Auto Layout:通过代码添加约束
- VS2010灵活运用快捷操作功能(总结)
- ORA-00304: requested INSTANCE_NUMBER is busy
- 在Linux系统上编译安装eAccelerator
- <Unity3D>实例化UGUI中GameObject 并设置它的位置
- struts2 Double类型上传默认转换为String
- eclipse中英文大小不一致解决方法
- Spring的IOC容器—scope作用域