问候,Spring:为什么不能以分隔的.xml配置两个ServletContextPropertyPlaceholderConfigurer?
我正在研究基于弹簧的Web应用程序。情况是:
- 有两个.xml文件,一个应用程序的context.xml,另一种是默认的context.xml
- 应用程序的context.xml将负载Web上下文当Tomcat启动,其配置在web.xml
应用程序的context.xml ServletContextPropertyPlaceholderConfigurer加载一些properties.and进口默认的context.xml
,因为默认的context.xml是在另一个项目,我希望它有它自己的。特性(缺省context.propertie s)文件并设置一个ServletContextPropertyPlaceholderConfigurer来加载属性。
当前结果是:在default-context.properties属性未加载,并且在默认的context.xml的ServletContextPropertyPlaceholderConfigurer不inited。据报道
无法解决占位符XXXXXX”
我尝试了一些组合,
1.to在应用程序的context.xml的ServletContextPropertyPlaceholderConfigurer负荷default-context.properties,它的工作。
2.to application-context.xml中加载default-context.properties的PropertyPlaceholderConfigurer,不工作。我猜是因为Pro pertyPlaceholderConfigurer无法加载到servlet上下文?
3.在default-context.xml中双向加载default-context.properties(ServletContextPropertyPlaceholderConfigurer或PropertyPlaceholderConfigurer) 无效。
我不明白为什么只有一个ServletContextPropertyPlaceholderConfigurer可以在servlet上下文中配置?
配置是这样的:在应用程序的context.xml
<class="org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:etc/system.properties
</value>
...
在默认的context.xml:
<bean id="tempName123"
class="org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer" >
<property name="locations">
<list>
<value>classpath:etc/default-datasource.properties</value>
</list>
</property>
</bean>
Ritesh,谢谢你的回复。我试过这种方法,没有工作。第二个ServletContextPropertyPlaceholderConfigurer bean不是init,也不是上下文加载的。 – Yang 2010-12-06 01:58:51