2012-07-25 74 views
1

我有2個基於spring的jar文件 - parent.jar和child.jar。在依賴jar中的spring appContext.xml無法加載屬性文件。

parent.jar有parent_applicationContext.xml和它加載如下

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
    <property name="locations"> 
    <list> 
     <value>classpath:app.properties</value> 
    </list> 
    </property> 
    <property name="ignoreUnresolvablePlaceholders" value="true"/> 
</bean> 

<bean id="appBean" class="com.foo.App" > 
    <property name="appName" value="${app.name}" /> 
</bean> 

child.jar包括parent.jar的依賴,並有自己的applicationContext.xml屬性文件。 但是,當我執行child.jar時,我無法看到parent_applicationContext.xml能夠加載app.properties。

我看到錯誤消息

Invalid bean definition with name 'appBean' defined in class path resource [parent_applicationContext.xml]: Could not resolve placeholder 'app.name' 

任何線索?

回答

0

我設法在child.jar再次加載的屬性來解決它!applicationContext.xml中,像這樣,

<context:property-placeholder location="monitordb.properties" />