假设我在下面的项目中定义了两个Maven依赖项。Maven依赖于不同范围内的依赖关系
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.3.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mycompany.library</groupId>
<artifactId>mylibrary</artifactId>
<version>1.0.1</version>
<scope>compile</scope>
</dependency>
然后,在mylibrary中,我也有一个依赖定义如下。
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.3.1</version>
<scope>compile</scope>
</dependency>
当我打包我的项目时,我没有看到xstream打包在其中。我认为项目的xstream依赖范围'test'正在覆盖mylibrary的xstream依赖范围'compile'。
在这种情况下,在整个项目中包含xstream的最佳方式是什么,以便在打包到项目中时子模块可以访问它?
我已阅读Apache Maven网站对Transitive依赖关系的解释,但我正在努力理解它的含义,并且找出了这种情况下的最佳实践。
来自Apache Maven网站: - 编译 这是默认范围,如果没有指定,则使用。编译依赖关系在项目的所有类路径中都可用。而且,这些依赖关系会传播到依赖项目。 –
也许我原来的问题导致了混乱,因为我使用了“子模块”。请参阅我上面编辑的问题。 –
是的,我更关心测试范围。 – aperkins