Spring boot maven插件:包括测试资源

问题描述 投票:1回答:1

我具有以下目录结构:

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>

我尝试不成功,包括标志addResourcesuseTestClasspath,即使阅读文档(https://docs.spring.io/spring-boot/docs/current/maven-plugin/start-mojo.html),我也真的无法弄清楚它们应该如何工作。

提前感谢。

spring spring-boot maven-plugin spring-boot-maven-plugin
1个回答
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>
© www.soinside.com 2019 - 2024. All rights reserved.