maven子模块test类依赖其他子模块test类
·
在 Maven 中,子模块之间的依赖关系可以通过在 pom.xml 文件中声明依赖来实现。
如果希望一个子模块的测试类依赖于另一个子模块的测试类,需要在被依赖的子模块的 pom.xml 文件中声明一个 test 作用域的依赖。这将使被依赖的子模块的测试类的依赖项也成为依赖于当前子模块的测试类的一部分。
例如,假设您的项目结构如下:
parent
├── module1
└── module2
其中 module1 包含一个名为Module1Test的测试类,该测试类依赖于 module2 中的名为 Module2Test 的测试类。为了实现这个依赖关系,您需要在 module1 的 pom.xml 文件中声明以下依赖关系:
<dependency>
<groupId>com.example</groupId>
<artifactId>module2</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
引入后update maven ,如果还不行,再加入<classifier>tests</classifier>,即
<dependency>
<groupId>com.example</groupId>
<artifactId>module2</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
每次修改完成后,都要整个项目update maven


更多推荐
所有评论(0)