簡體   English   中英

依賴jar中的spring appContext.xml無法加載屬性文件。

[英]spring appContext.xml in dependent jar fails to load property file.

我有2個基於spring的jar文件-parent.jar和child.jar。

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'

有任何線索嗎?

我設法通過再次在child.jar!applicationContext.xml中加載屬性來解決該問題,

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM