【发布时间】:2018-11-24 02:07:24
【问题描述】:
我有一个 maven 项目,其结构如下
- Root pom.xml
- module1
- module2
module2 是一个使用 Spring Boot 注解的集成测试模块 -
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Config.class, webEnvironment = RANDOM_PORT)
module2 依赖于 module1,当项目使用 spring-boot-maven-plugin 构建时,它会被重新打包并@ module1 中的 987654321@; This can be solved using the classifier as follows
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<classifier>exec</classifier>
</configuration>
</execution>
</executions>
</plugin>
现在的问题是,当运行 module2 集成测试时,无法再找到主类,我猜这是因为 module2 现在正在使用原始工件并且不是重新包装的。
目标的执行默认值 org.springframework.boot:spring-boot-maven-plugin4.6.18.RELEASE:repackag e failed: 找不到主类
当涉及到 Spring Boot 和集成测试时,如何解决这个问题以及项目结构的最佳实践是什么?
【问题讨论】:
标签: java spring maven spring-boot integration-testing