當我使用下面的Spring XML文件類路徑屬性,類路徑中的Spring MVC
<bean class="com.fritolay.suppliernet.common.lastresorthandler.impl.SingletonPropertiesRepository">
<property name="propertiesFile" value="classpath:ecr/sample.properties" />
</bean>
在這種情況下沒有服務器尋找屬性文件中的應用程序?
我的問題是,我有兩個模塊[1.Web Project 2.Java Project]。我定義的Web項目這個XML文件,並把屬性文件下的Java項目的src folder.But當我部署我的應用我收到以下錯誤:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'propertiesFile' threw exception; nested exception is java.io.FileNotFoundException: class path resource [ecr/sample.properties] cannot be resolved to absolute file path because it does not reside in the file system: zip:C:/Oracle/Middleware/user_projects/domains/sample/servers/AdminServer/tmp/_WL_user/_appsdir_supplier-net_ear/6e86rt/sample-service.jar!/ecr/sample.properties
是'ecr'包中的屬性文件嗎? bean本身是否處理類路徑資源? – 2012-01-02 14:49:12
是的屬性文件在ecr package.Yes中的bean類是它的處理資源文件如下。 public void setPropertiesFile(Resource propertiesFile)throws IOException {this.repository.setPropertiesFiles(Collections.singletonMap( DEFAULT_KEY,propertiesFile)); } – Ran 2012-01-02 14:52:25
您是否檢查過在/ WEB-INF/classes目錄中或在您的類正在打包的JAR文件中部署的屬性文件(如果是)? – 2012-01-02 14:54:17