简体   繁体   English

命令行mvn参数可阻止spring-boot-maven-plugin执行运行

[英]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.

相关问题 使用带有exec分类器的spring-boot-maven-plugin,但无法再从IDE运行该应用程序 - using spring-boot-maven-plugin with exec classifier, but can't run the app from IDE anymore spring-boot-maven-plugin,mvn release:准备不对pom.xml提交更改 - spring-boot-maven-plugin, mvn release:prepare not committing changes to pom.xml spring-boot-maven-plugin包括工作区中的其他项目 - spring-boot-maven-plugin include other projects from workspace 无法在 spring-boot-maven-plugin 中分叉 - Unable to fork in spring-boot-maven-plugin Maven - 无法执行目标 org.springframework.boot:spring-boot-maven-plugin:2.4.1:run - Maven - Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.4.1:run 无法执行目标 org.springframework.boot:spring-boot-maven-plugin:2.2.2.RELEASE:run - Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.2.2.RELEASE:run Maven mvn spring-boot:run - 找不到本地库,在命令行失败,但在 STS4 中运行 - Maven mvn spring-boot:run - cannot find local library, fails on command line but runs in STS4 Spring-Boot-Maven-Plugin - 将资源复制到WAR主目录的命令 - Spring-Boot-Maven-Plugin - Command to Copy Resources into WAR Main Directory 插件 spring-boot-maven-plugin 的错误解析版本' - Error resolving version for plugin spring-boot-maven-plugin' org.apache.maven.lifecycle.LifecycleExecutionException:无法执行目标 org.springframework.boot:spring-boot-maven-plugin:2.4.8:run - org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.4.8:run
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM