【发布时间】:2023-03-05 19:38:02
【问题描述】:
我有以下项目结构:
parent pom
|
- Core module - pom
- Dist - pom
- Integration test - pom
Spring boot 主类在核心模块中。集成测试将进入集成测试文件夹。
我正在尝试使用 spring-boot-maven-plugin 进行集成测试。 我在集成测试模块中完成了以下 pom 配置。 start-class 属性在父 pom 中设置:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>${start-class}</mainClass>
<layout>JAR</layout>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
<execution>
<id>pre-integration-test</id>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>post-integration-test</id>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
但是我在父 pom 上的 mvn clean install 上收到以下错误:
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.5.10.RELEASE:start (pre-integration-test) on pro
ject: Spring 应用程序在配置的超时之前没有启动(30000ms -> [Help 1] [错误]
问题:
- 这种项目结构是组织集成的最佳方式吗 测试?
- 如何以及在何处将主类的路径提供给 spring-boot-maven-plugin 正确吗?即使我给它也不起作用 它在集成模块或父 pom 中,即使给出了 您通常会执行的相对路径(例如 ../core-module/)
- 测试类本身上的 maven-failsafe-plugin 和 spring 注释似乎足以运行集成测试。那么首先集成测试和spring boot maven插件之间有什么关系吗?除了打包成可执行文件之外,spring boot maven插件还需要什么。我有这种困惑,因为它的目标是开始预集成测试和集成后测试,但我不明白为什么需要它。
PS:我检查了几个具有类似问题的问题,但没有人回答我针对给定项目结构提出的问题。
【问题讨论】:
标签: maven spring-boot spring-boot-maven-plugin