我具有以下目录结构:
src
|
|___ main
|
|___ test
|
|___resources
在阶段集成前测试中运行开始目标(spring-boot:start,不同于spring-boot:run)时,我想将所有来自测试资源的文件包含在类路径中。
我的pom.xml是:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
<execution>
<id>pre-integration-test</id>
<goals>
<goal>start</goal>
</goals>
<configuration>
<wait>1000</wait>
<maxAttempts>30</maxAttempts>
</configuration>
</execution>
<execution>
<id>post-integration-test</id>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
我尝试了包括标志addResources
或useTestClasspath
的尝试,但没有成功,即使阅读文档(https://docs.spring.io/spring-boot/docs/current/maven-plugin/start-mojo.html),我也真的不知道它们应该如何工作。
谢谢。
答案 0 :(得分:0)
这是一个有效的Maven配置:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.2.2.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
<execution>
<id>pre-integration-test</id>
<goals>
<goal>start</goal>
</goals>
<configuration>
<classesDirectory>${project.build.testOutputDirectory}:${project.build.outputDirectory}</classesDirectory>
<wait>1000</wait>
<maxAttempts>30</maxAttempts>
</configuration>
</execution>
<execution>
<id>post-integration-test</id>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>