Java 防止springboot故障保护插件默认执行
我有一个示例springboot java应用程序。 这是我的pom文件Java 防止springboot故障保护插件默认执行,java,maven,spring-boot,maven-surefire-plugin,Java,Maven,Spring Boot,Maven Surefire Plugin,我有一个示例springboot java应用程序。 这是我的pom文件 <groupId>com.sample.this</groupId> <artifactId>example</artifactId> <version>1.0-SNAPSHOT</version> <parent> <groupId>org.springframework.boo
<groupId>com.sample.this</groupId>
<artifactId>example</artifactId>
<version>1.0-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.2.RELEASE</version>
</parent>
<profiles>
<profile>
<id>profile1</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<id>id1</id>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
当我删除springboot starter父pom时,故障保护插件会按预期运行一次。这是日志-
[INFO] --- maven-failsafe-plugin:2.22.1:integration-test (id1) @ junit.example ---
所以,如果springboot在我的pom中找不到默认的故障保护插件,它会在集成测试阶段运行默认的故障保护插件
我无法在故障保护插件声明中添加默认执行步骤。
如何停止springboot以停止运行其故障保护插件
我可以在我的pom中添加这个来让它工作-
<execution>
<goals>
<goal>integration-test</goal>
</goals>
<configuration>
<skipITs>true</skipITs>
</configuration>
</execution>
集成测试
真的
但这看起来并不直观
还有别的办法吗
我不想在我的pom文件中添加springboot插件以下可能是删除groupId和execution id标记的解决方案:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.2.RELEASE</version>
</parent>
<profiles>
<profile>
<id>profile1</id>
<build>
<plugins>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
请检查以下内容。在此,已禁用默认执行:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.2.RELEASE</version>
</parent>
<profiles>
<profile>
<id>profile1</id>
<build>
<plugins>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<id>default</id>
<phase>none</phase>
</execution>
<execution>
<id>id1</id>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
org.springframework.boot
spring启动程序父级
2.1.2.1发布
简介1
maven故障保护插件
违约
没有一个
id1
集成测试
为什么要为maven failsafe插件添加另一个配置..Spring Boot已经定义了一个。。。?你为什么想要另一个?我有一些复杂的测试需求,默认执行无法满足。这意味着什么?如果你真的有复杂的测试要做,我的经验是你做错了…只是猜测…我需要用不同的配置运行所有的it多次。因此,我的配置文件将包含多个执行步骤。所有执行步骤都将有一个id,并且不会有默认执行。所以spring将使用failsafe运行它的默认执行步骤,我不希望这样。可能是重复的,但我需要id,因为会有多个执行步骤。
[INFO] ------------------------------------------------------------------------
[INFO] Building test 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-failsafe-plugin:2.22.1:integration-test (default) @ test ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-failsafe-plugin:2.22.1:verify (default) @ test ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.2.RELEASE</version>
</parent>
<profiles>
<profile>
<id>profile1</id>
<build>
<plugins>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<id>default</id>
<phase>none</phase>
</execution>
<execution>
<id>id1</id>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>