我创建了一个包含多个Java项目的项目,每个项目都有自己的依赖项。
一个项目是主项目并使用所有其他项目,但不是直接项目。例如:
假设我有三个项目的A,B和C,A是主项目(应用程序)。 A使用B作为依赖,而B使用C作为依赖,项目C有自己的外部依赖。
我的团队中的每个人都有权下载一个项目,并根据需要使用其他项目作为依赖项。 问题出现在开发主项目的团队中,Maven没有下载B& C对本地计算机的依赖关系。
这些是每个人的pom文件:
A(主要项目)
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.a.c</groupId>
<artifactId>D</artifactId>
<version>1.0.0</version>
<classifier>jar-with-dependencies</classifier>
<exclusions>
<exclusion>
<artifactId>commons-io</artifactId>
<groupId>commons-io</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.a.c</groupId>
<artifactId>B</artifactId>
<version>0.0.1</version>
<classifier>jar-with-dependencies</classifier>
</dependency>
</dependencies>
</dependencyManagement>
B:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.a.c</groupId>
<artifactId>C</artifactId>
<version>0.0.1</version>
<classifier>jar-with-dependencies</classifier>
</dependency>
</dependencies>
</dependencyManagement>
C:
<dependencies>
<dependency>
<groupId>org.jsystemtest</groupId>
<artifactId>jsystemApp</artifactId>
<version>6.1.01</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.50.0</version>
</dependency>
</dependencies>
为了在不下载每台机器的源代码的情况下获取B和C的依赖关系,我应该设置哪种配置?
答案 0 :(得分:2)
您似乎将<dependencyManagement>
与<dependencies>
混淆了。 A和B中的<dependencyManagement>
仅设置依赖项的版本而不包括它们。这就是为什么Maven不会下载B的依赖关系而不是C的依赖关系(除非你在A和B中都有一个额外的<dependency>
部分,你没有显示)。