https://docs.spring.io/spring-boot/docs/current/maven-plugin/usage.html
我有一个项目,有 2 个模块。
[Parent]
|-pom.xml
| [SpringBoot2App]
| |-pom.xml
| [test]
| |-pom.xml (start goal here!)
我想在另一个模块的单独项目中运行集成测试(maven 故障安全插件)。
在父模块的集成测试期间,是否可以配置 spring boot maven 插件来启动/停止子模块?
我尝试过类似的事情但没有成功
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.SimpleServiceApplication</mainClass>
<classesDirectory>../SpringBoot2App/target/classes</classesDirectory>
<folders>
<param>../SpringBoot2App/target/test-classes</param>
</folders>
</configuration>
<executions>
<execution>
<goals>
<goal>start</goal>
</goals>
<phase>pre-integration-test</phase>
</execution>
</executions>
</plugin>
这是行不通的。
在阅读插件超类的源代码后,我还尝试添加“项目”参数https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/启动/maven/AbstractRunMojo.java
<configuration>
<mainClass>com.SimpleServiceApplication</mainClass>
<project>${project.parent.collectedProjects[0]}</project>
</configuration>
正如调试所示,这指的是正确的项目,但也不起作用。
请不要评论 [0],我知道 [0] 并不干净,并且是一个需要直接了解父 pom 模块顺序的耦合。
我在 org/springframework/boot/SpringApplication 上收到 java.lang.NoClassDefFoundError
我将starter-web项目添加到测试pom.xml中,结果相同