我有一个属性文件 -
application.properties(内容如下)
core.microsite=q=MarketId:${marketId}&q=PresaleOff
这是我的弹簧配置 xml -
<bean id="myBean" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="ignoreUnresolvablePlaceholders" value="true" />
<property name="location" value="classpath:/application.properties" />
</bean>
<bean id="MyQueryBuilder" class="com.search.builder.impl.MyQueryBuilder">
<property name="queryTemplateMap">
<map>
<entry key="microsite" value="${core.microsite}" />
</map>
</property>
</bean>
现在在服务器启动(tomocat)我得到这个异常 -
ug 29, 2012 11:50:05 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'MyQueryBuilder' defined in URL [jar:file:/C:/apache-tomcat-6.0.35/webapps/my-service/WEB-INF/lib/my-app-1.0.2.RC8-SNAPSHOT.jar!/META-INF/spring/config/app-context.xml]: Could not resolve placeholder 'marketId'
at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(PropertyPlaceholderConfigurer.java:287)
at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:75)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:663)
它显然失败了,因为 core.microsite 属性内部还有一个占位符${marketId}
如何解决这个问题?
将“ignoreUnresolvablePlaceholders”设置为 true 应该有效(理论上)。不知道现在该怎么办?
感谢任何指针!
谢谢。