[英]Command line mvn parameter to stop spring-boot-maven-plugin from executing run
I'm developing a Spring Boot application and as part of the Integration Test phase of my maven project, I have configured the spring-boot maven plugin to start up and shut down during the pre and post integration test parts of the build as follows: 我正在开发一个Spring Boot应用程序,并且在我的maven项目的Integration Test阶段中,我已经配置了spring-boot maven插件,以在构建的集成测试的前期和后期进行以下操作:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>pre-integration-test</id>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>post-integration-test</id>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
However, I did this just so that my developers can run their tests against a local instance of the service. 但是,我这样做只是为了让我的开发人员可以针对服务的本地实例运行测试。 On Jenkins, I would run the tests against an external service where I had deployed the service and I do not need the Spring Boot application to be spun up within the Jenkins job. 在Jenkins上,我将对部署了该服务的外部服务运行测试,并且不需要在Jenkins作业中启动Spring Boot应用程序。
Is there a way for me to explicitly stop the spring-boot maven plugin from starting up the service via a mvn command line override? 有没有办法让我通过mvn命令行覆盖明确阻止spring-boot maven插件启动服务?
Sure, you can expose a property for it, something like 当然,您可以为其公开一个属性,例如
<properties>
<skip.it>false</skip.it>
</properties>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>pre-integration-test</id>
<goals>
<goal>start</goal>
</goals>
<configuration>
<skip>${skip.it}</skip>
</configuration>
</execution>
<execution>
<id>post-integration-test</id>
<goals>
<goal>stop</goal>
</goals>
<configuration>
<skip>${skip.it}</skip>
</configuration>
</execution>
</executions>
</plugin>
Once you have that, run your command as follows: mvn verify -Dskip.it=true
and the Spring Boot application will not be started as part of your integration tests. 一旦有了它,请按如下所示运行命令: mvn verify -Dskip.it=true
并且不会在集成测试中启动Spring Boot应用程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.