【问题标题】:Stop spring boot from executing failsafe plugin阻止 spring boot 执行故障保护插件
【发布时间】:2019-04-24 11:57:10
【问题描述】:

我有一个 Spring Boot 应用程序。

将 sprinboot pom 添加为父项

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.2.RELEASE</version>
    </parent>

这是 spring-boot-starter-parent-2.1.2 中&lt;pluginmanagement&gt; 部分下提到的故障安全依赖项

                <plugin>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <executions>
                        <execution>
                            <goals>
                                <goal>integration-test</goal>
                                <goal>verify</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <classesDirectory>${project.build.outputDirectory</classesDirectory>
                    </configuration>
                </plugin>

我还在我的项目构建阶段在不同的配置文件下定义了故障保护。 我所有的 IT 文件都以“IT”结尾。

        <profile>
            <id>myProfile</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <version>2.22.1</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>integration-test</goal>
                                    <goal>verify</goal>
                                </goals>
                                <configuration>
                                    <groups>${it.groups}</groups>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

当我运行mvn integration-test -PmyProfile 时, maven 首先开始运行 spring 依赖项中提到的默认故障安全执行。然后它从我的 pom 运行插件。

这导致我的集成测试运行两次。

我不希望 IT 使用 spring pom 中提到的故障安全插件运行。

我该怎么做? 我不想在我的 pom 中重新定义插件。

我只是想删除spring-starter pom.xml中提到的目标

【问题讨论】:

  • 请发布您的完整 pom 文件。此外,您如何命名您的测试?
  • 编辑回答您的问题。完整的 pom 文件会很大。我已经发布了相关的行
  • 很确定在pluginmanagement 中有插件是问题所在。如果您只希望它在调用配置文件时运行,则只需要配置文件中的配置。
  • 是的。但是我如何摆脱来自 pluginmanagement 的那个插件呢?这是在 springboot pom 中定义的,我已将其包含为父 pom
  • 找到了解决方案。我的 有一个 这就是为什么 springboot 没有将它与默认运行合并。

标签: java maven spring-boot maven-failsafe-plugin


【解决方案1】:

我看到您找到了解决问题的方法。您可以忽略父插件,如图here

注意&lt;phase&gt;none&lt;/phase&gt;

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <executions>
        <execution>
            <phase>none</phase>
        </execution>
    </executions>
</plugin>

调用配置文件 myProfile 将按预期运行。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-10-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-08
    • 2021-09-23
    • 2011-06-26
    相关资源
    最近更新 更多