使用Spring将war文件的WEB-INF目录下的资源导入applicationContext文件

时间:2016-09-30 09:57:08

标签: spring

我在我的项目中使用Spring框架。我想导入applicationContext配置文件中war文件的/WEB-INF/CustomerService/spring-integration/Jobs/目录下的所有xml资源/文件。我试过以下几行代码,但没有工作。

<import resource= /WEB-INF/CustomerService/spring-integration/Jobs/*.xml"/>

<import resource="file:**/WEB-INF/CustomerService/spring-integration/Jobs/*.xml"/>

<import resource="file:///WEB-INF/CustomerService/spring-integration/Jobs/*.xml"/>

<import resource="file:WEB-INF/CustomerService/spring-integration/Jobs/*.xml"/>

有关如何使用Spring从war-file的WEB-INF加载的任何想法?

2 个答案:

答案 0 :(得分:3)

WEB-INF目录路径在独立Spring项目中不能作为类路径使用。所以,我已经将配置文件移动到src/resources文件夹,无需任何麻烦就可以导入它们。

答案 1 :(得分:0)

尝试使用classpath导入另一个XML配置文件。像这样:

<import resource="classpath:your_config.xml"/>

假设请求的配置文件位于类路径