Could not resolve placeholder 解决方案
来源:互联网 发布:onavo protect mac版 编辑:程序博客网 时间:2024/09/21 06:36
用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"属性,注意必须都要加上- <context:property-placeholder location="xxx.properties" ignore-unresolvable="true" />
- <context:property-placeholder location="yyy.properties" ignore-unresolvable="true"
- />
在Spring 2.5中,<context:property-placeholder>没有ignore-unresolvable属性,此时可以改用PropertyPlaceholderConfigurer。其实<context:property-placeholder location="xxx.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属性。
- <context:property-placeholder location="WEB-INF/config/db/XX.properties" />
- <context:property-placeholder location="WEB-INF/config/dfs/XX.properties" />
在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>
阅读全文
0 0
- "Could not resolve placeholder"解决方案
- "Could not resolve 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"的解决方案
- Spring中报"Could not resolve placeholder"的解决方案
- Spring中报"Could not resolve placeholder"的解决方案
- Could not resolve placeholder 参考
- spring Could not resolve placeholder
- spring报“Could not resolve placeholder”错误
- Could not resolve placeholder 'jdbc.driverClass'
- com.github.pagehelper:pagehelper:jar:3.4.2-fix
- 自定义证书调试问题
- 菜鸟进击过程中忽略的知识点
- AngularJS(七)迭代3
- 我的分享:阿里云幸运券(云服务器ECS,关系型数据库RDS,云虚拟主机)
- Could not resolve placeholder 解决方案
- 接口限流算法总结
- 非wifi网络用户选择图片加载模式
- 集合---- Set (1)
- Linux Device Tree
- Statement、Preparestatement和CallableStatement
- CSU
- Linux -- 第一部分 shell
- 程序员面试笔试宝典