org.springframework.beans.factory.BeanDefinitionStoreException:
Invalid bean definition with name '******' defined in null: Could not resolve placeholder 'displayName'
我未深究原因,猜测原因如下:
有可能是因为你配置了多个 org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
这个配置用于 xml 中的占位符,如下:
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
假设 a.xml 配置了一个 PropertyPlaceholderConfigurer ,并且成功了。
后来,b.xml 也配置了一个 PropertyPlaceholderConfigurer ,这时候如果不做特别配置,b.xml 里配置的placeholder将无法使用,并报上面的错误。
************************************************************************************************************
解决方法:a.xml中配置第一个 PropertyPlaceholderConfigurer 时,将ignoreUnresolvablePlaceholders的值设为true
如下所示:
<bean id="myConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:jdbc.properties</value>
</list>
</property>
<property name="ignoreUnresolvablePlaceholders" value="true" />
</bean>
这个配置告诉spring,当某个placeholder无法找到时,先不要报错,并尝试用另一个PropertyPlaceholderConfigurer来设置placeholder的值。
原文:http://blog.csdn.net/longerandlonger/article/details/7193160
本文解析了Spring中因配置多个PropertyPlaceholderConfigurer导致的BeanDefinitionStoreException异常,提供了配置ignoreUnresolvablePlaceholders参数的解决方案。

813

被折叠的 条评论
为什么被折叠?



