Im trying to run a simple maven project, composed of a parent pom and (one or more) child projects. Running each child in isolation works great, but when I add the <parent>
data, child projects开发者_运维技巧 wont resolve dependencies.
When I run $mvn test
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[...]symbol: class TestCase
[...]services\TikalWebServiceTest.java:[3,22] package junit.framework does not exist
[...]services\TikalWebServiceTest.java:[4,22] package junit.framework does not exist
In the child project, its pom.xml
I declared the junit dependency
<parent>
<artifactId>myapp</artifactId>
<groupId>com.some.app</groupId>
<version>1.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
[................]
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
In my parent project I also included this dependency, and also some repo information
<repositories>
<repository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
<id>central</id>
<name>Maven Repository Switchboard</name>
<url>http://repo1.maven.org/maven2</url>
</repository>
</repositories>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
Dependencies are also there in the effective-pom
<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
精彩评论