我是maven的新手。我正在将现有的多级ant项目迁移到maven,我面临调用或导入其他项目资源的问题。项目结构如下所示。
|---+- Common-Proj
| |------ src/main/java
| |---+-- src/main/resources
| |----- resource.xml
|
|
|---+-- Web-Proj
| |--------- src/main/java
| |---+----- src/main/resources
| | |----- context.xml
| |
| |---+----- src/main/webapp
| | |--+-- WEB-INF
| | |-- web.xml
Common proj是一个简单的maven项目,其中包含一些第三方依赖项和一些常见的api和资源。
**The pom.xml of common-proj is something like this.**
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.common</groupId>
<artifactId>CommonProj</artifactId>
<version>0.0.1-SNAPSHOT</version>
.
.
all 3rd party dependencies.
.
.
</project>
具有共同依赖性的Web-Proj。 web-proj的pom.xml就是这样的。
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.webproj</groupId>
<artifactId>webProj</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.common</groupId>
<artifactId>CommonProj</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
</build>
</project>
我从web.xml调用context.xml,现在问题是**我正在尝试从context.xml文件**导入common-proj中的resource.xml,同时启动tomcat我收到以下错误
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:resource.xml]
Offending resource: class path resource [context.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [resource.xml]; nested exception is java.io.FileNotFoundException: class path resource [resource.xml] cannot be opened because it does not exist
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
我假设容器试图在Web-Proj的资源目录中找到resource.xml。相反,它应该从jar中选择。
提前完成。