我们使用的是JBOSS 5.1.0.GA和spring集成框架。我们将配置文件放在JBOSS的conf目录下,以便从类路径中读取它们。但是现在我们被告知应该将所有配置文件从conf目录移动到war文件的WEB-INF目录。当我们把文件放在conf目录下时,一切都运行得很好。
<bean id="xyz" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="locations">
<list>
<value>classpath:CustomerService/property-files/*.properties</value>
</list>
</property>
</bean>但是,当我们通过进行以下更改将配置文件从conf目录移动到WEB-INF目录时,我们会得到异常java.io.FileNotFoundException。
<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)有谁知道该怎么做吗?
发布于 2016-10-12 20:28:28
WEB-INF目录路径在独立的Spring项目中不能作为类路径使用。因此,我已经将配置文件移动到src/resources文件夹,以便轻松地导入它们。
发布于 2016-08-18 18:45:21
将它们放在类路径中(通过某种构建方法)。
/WEB-INF/classes/CustomerService/property-files/*.propertieshttps://stackoverflow.com/questions/39016101
复制相似问题