我正在尝试研究 Maven,因此我创建了一个简单的 Web 应用程序,如“Maven by Example”一书中提供的那样,并且在该应用程序中,我在 simple-parent 中拥有 simple-model 作为依赖项的 simple-weather maven 项目。
我刚刚复制了 pom.xml(仅对休眠工件版本进行了调整),当我在“simple-model”上运行“mvn install”时,它构建正常,但是当我在“simple”上运行“mvn install”时-weather”它没有构建好,因为它说它没有找到与简单模型依赖项相关的包。
注意:如果我创建了两个 Eclipse 项目并关联了 simple-model”,它可以编译,因此不存在与项目编译相关的问题。
参见 pom.xml。我想问题出在 pom.xml 上,但我不知道该怎么做。我已经尝试以多种方式修复,但根本没有成功。
我什至已经将组和工件 ID 从 simple-model 复制到 simple-weather 以保证这不是打字问题。:-(
//简单模型-> 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>
<parent>
<groupId>org.sonatype.mavenbook.multispring</groupId>
<artifactId>simple-parent</artifactId>
<version>1.0</version>
</parent>
<artifactId>simple-model</artifactId>
<packaging>jar</packaging>
<name>Simple Object Model</name>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.5.6-Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>3.2.0.Final</version>
</dependency>
</dependencies>
</project>
//简单天气 -> 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>
<parent>
<groupId>org.sonatype.mavenbook.multispring</groupId>
<artifactId>simple-parent</artifactId>
<version>1.0</version>
</parent>
<artifactId>simple-weather</artifactId>
<packaging>jar</packaging>
<name>Simple Weather API</name>
<dependencies>
<dependency>
<groupId>org.sonatype.mavenbook.multispring</groupId>
<artifactId>simple-model</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
查看错误消息:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.
3.2:testCompile (default-testCompile) on project simple-weather: Compilation fai
lure: Compilation failure:
[ERROR] \mavenTest\ch-multi-spring\simple-parent\simple-weather\src\test\java\or
g\sonatype\mavenbook\weather\yahoo\YahooParserTest.java:[8,43] error: package or
g.sonatype.mavenbook.weather.model does not exist
任何援助将不胜感激。先感谢您。