我们使用JBOSS 5.1.0.GA和spring集成框架。我们将配置文件放在JBOSS的conf
目录下,以便从类路径中读取它们。但是现在我们被告知我们应该将所有配置文件从conf
目录移动到war文件的WEB-INF
目录。一切工作正常当我们把文件放在conf
目录下。将文件放在WEB-INF目录下并阅读它们
<bean id="xyz" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="locations">
<list>
<value>classpath:CustomerService/property-files/*.properties</value>
</list>
</property>
</bean>
但是,当我们通过以下的改变,我们所得到的异常java.io.FileNotFoundException
从conf
目录移动配置文件以WEB-INF
目录。
<bean id="xyz" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="locations">
<list>
<value>/WEB-INF/CustomerService/property-files/*.properties</value>
</list>
</property>
</bean>
异常的详细信息:
java.io.FileNotFoundException: URL [jndi:/localhost/pqawdTestWebApp/WEB-INF/CustomerService/spring-integration/Jobs/] cannot be resolved to absolute file path because it does not reside in the file system: jndi:/localhost/pqawdTestWebApp/WEB-INF/CustomerService/spring-integration/Jobs/
at org.springframework.util.ResourceUtils.getFile(ResourceUtils.java:205)
at org.springframework.core.io.AbstractFileResolvingResource.getFile(AbstractFileResolvingResource.java:52)
at org.springframework.core.io.UrlResource.getFile(UrlResource.java:169)
at org.springframework.core.io.support.PathMatchingResourcePatternResolver.doFindPathMatchingFileResources(PathMatchingResourcePatternResolver.java:526)
任何人有做什么想法?
没关系。但是如何从web.xml和其他spring配置文件中读取它们呢?我们需要指定那里读取什么路径? –
如前所述,'classpath:CustomerService/property-files/...'(在spring中)。剩下的就是普通的资源文件,'getResourceAsStream(“/ ...”)'或其他什么, –
这意味着我们需要一个spring bean来读取WEB-INF文件夹下的配置文件。我对么? –