我有一些Spring文件依赖于其他文件中的属性占位符。从本质上讲,我有3个XML文件,像这样:IoC容器属性继承
one.xml:
<?xml version="1.0"?>
<beans ...>
<import resource="two.xml"/>
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>/WEB-INF/your.properties</value>
</list>
</property>
</bean>
<bean id="clasher" class="whatever.Clash">
<property name="name" value="${route.one}"/>
</bean>
</beans>
two.xml:
<?xml version="1.0"?>
<beans ...>
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>/WEB-INF/my.properties</value>
</list>
</property>
</bean>
</beans>
my.properties:
route.one = Why Not?
your.properties:
entirely.unrelated = true
我越来越基本上看起来像这样的错误:
Exception in thread "Launcher:/serverling" org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'clasher' defined in ServletContext resource [/WEB-INF/one.xml]: Could not resolve placeholder 'route.one'
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)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:638)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:407)
at org.red5.server.tomcat.TomcatLoader$1.run(TomcatLoader.java:594)
有没有一种方法,使财产占位符整个容器继承?
我最初的假设是,由于容器并不关心哪些文件bean存在,它只会配置所有的bean,然后运行通过容器中的所有定义的bean,并使用多个属性占位符配置器来填充它们。
为什么不在此示例workingL