2012-12-03 43 views
0

我有資源文件的以下彈簧配置,當我在eclipse環境中執行時,它工作得很好。但是,當我將應用程序打包到JAR中並執行它時,不會提供屬性文件資源。春天3.2資源文件加載問題

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

<!-- define the properties file to use --> 
<util:properties id="appProperties" location="classpath:Application.properties" /> 

當我看到jar文件時,所有文件都存在。我正在使用maven來構建程序集。

項目結構:

ProjName | | - 主 | - java的 | - 資源

而且,我使用使用這個鏈接(http://stackoverflow.com/questions/13615634/maven-build-assembly-with-行家配置依賴關係)

+0

你會得到一個異常嗎?你可以添加堆棧跟蹤? –

回答

1

目前沒有足夠的信息來確切知道發生了什麼。但在我看來,context.xml中存在一些混淆。首先,我建議用

代替
<context:property-placeholder location="classpath:/Application.properties, classpath:/database.properties" /> 
+0

gpa