【发布时间】:2019-04-25 22:39:18
【问题描述】:
我的目录结构如下:
src
|
|___ main
|
|___ test
|
|___resources
在 pre-integration-test 阶段运行启动目标(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),我也真的无法弄清楚它们应该如何工作。
提前致谢。
【问题讨论】:
-
使用 Maven 配置文件并创建一个测试配置文件不是更好的主意吗?我认为这就是使用 Maven 的方式。
标签: spring spring-boot maven-plugin spring-boot-maven-plugin