如何使用 Spring Cloud Contract Verifier 跳过测试生成 Maven 目标?

How to skip the test generation maven goal with Spring Cloud Contract Verifier?

我想测试一个服务 Consumer,它使用 FeignClient 调用我拥有的另一个服务 Producer。为了存根调用的服务,我在生产者上使用 spring-cloud-contract-verifier,在消费者上使用 spring-cloud-contract-stub-运行ner。

我的问题是我已经为生产者编写了集成测试,所以我只想生成存根并跳过测试生成。使用 spring-cloud-contract-maven-plugin,我试图只设置我需要的目标,但它仍在尝试 运行 测试。我怀疑我没有正确设置它...

<plugin>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-contract-maven-plugin</artifactId>
    <version>${spring-cloud-contract.version}</version>
    <extensions>true</extensions>
    <executions>
        <execution>
            <goals>
                <goal>convert</goal>
                <goal>generateStubs</goal>
            </goals>
            <configuration>
                <basePackageForTests>com.example</basePackageForTests>
            </configuration>
        </execution>
    </executions>
</plugin>

当我 运行 mvn clean install 时,它仍然需要一个 TestBase。我怎样才能跳过这个目标?

如果您查看文档 (https://cloud.spring.io/spring-cloud-static/spring-cloud-contract/1.2.4.RELEASE/spring-cloud-contract-maven-plugin/generateTests-mojo.html),您会发现您可以做很多事情。 -DskipTests-Dspring.cloud.contract.verifier.skip=true。始终阅读文档。