【发布时间】:2018-11-07 14:02:26
【问题描述】:
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>
这不起作用。
我也试过在阅读插件超类的源码后添加一个“project”参数 https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/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
我在测试pom.xml中添加了starter-web项目,结果一样
【问题讨论】:
标签: java maven spring-boot spring-boot-maven-plugin