could not resolve placeholder ${}
2016-03-07 11:28
190 查看
用spring 配置加载properties文件的时候,报Could not resolve placeholder 错误。
很有可能是使用了多个PropertyPlaceholderConfigurer或者多个<context:property-placeholder>的原因或者是多个PropertyPlaceholderConfigurer与<context:property-placeholder>混合使用。
解决方案:
在Spring3中可以用如下方式解决,找到所有[color=blue]<context:property-placeholder>[/color]
增加[color=red]ignore-unresolvable="true"[/color]属性,注意必须都要加上
在Spring 2.5中,<context:property-placeholder>没有ignore-unresolvable属性,此时可以改用PropertyPlaceholderConfigurer。其实<context:property-placeholder location="xxx.properties" ignore-unresolvable="true" />与下面的配置是等价的
这次报错因为配了 <property name="ignoreUnresolvablePlaceholders" value="true" /> 而没有配置<context:property-placeholder location="xxx.properties" ignore-unresolvable="true" />
很有可能是使用了多个PropertyPlaceholderConfigurer或者多个<context:property-placeholder>的原因或者是多个PropertyPlaceholderConfigurer与<context:property-placeholder>混合使用。
解决方案:
在Spring3中可以用如下方式解决,找到所有[color=blue]<context:property-placeholder>[/color]
增加[color=red]ignore-unresolvable="true"[/color]属性,注意必须都要加上
<context:property-placeholder location="xxx.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 name="ignoreUnresolvablePlaceholders" value="true" /> 而没有配置<context:property-placeholder location="xxx.properties" ignore-unresolvable="true" />
相关文章推荐
- 解决 IllegalArgumentException: Could not resolve placeholder in string value "${XXXXXX}"
- Spring中报"Could not resolve placeholder"的解决方案
- SpringMVC 整合shrio框架 Could not resolve placeholder '*******' in value "${*******}"
- Spring项目启动报"Could not resolve placeholder"解决
- spring错误 Could not resolve Spring property placeholder
- Could not resolve placeholder 'driverClasss' in string value "${driverClasss}"
- Spring中报"Could not resolve placeholder"的解决方案
- Could not resolve placeholder 解决方案
- Spring中报"Could not resolve placeholder"的解决方案
- Spring中报&quot;Could not resolve placeholder&quot;的解决方案
- "Could not resolve placeholder"解决方案
- Could not resolve placeholder 'mail.from' in string value "${mail.from}" 报错原因
- Could not resolve placeholder
- 解决 IllegalArgumentException: Could not resolve placeholder in string value "${XXXXXX}"
- BUG之Could not resolve placeholder...
- 启动错误:Could not resolve placeholder 'spring.datasource.url' in value "${spring.datasource.url}"
- Could not resolve placeholder 'spring.security.mapping.directory' in string value "${spring.security
- 解决 Could not resolve placeholder 'some.var.name' in string value
- spring Could not resolve placeholder
- Could not resolve placeholder 'driverClassName' in string value "${driverClassName}"