Spring Cloud Contract远程神器下载与本地冲突,如何临时解决?

Spring Cloud Contract remote artifact download clashes with local, how to make it temporary?

我在使用 Spring Cloud Contracts 2.0.0.M6 时遇到问题,或者我对如何正确配置存根 运行ner 测试有一些误解。

我想一直远程下载神器,所以我把stubsMode设为REMOTE

当我 运行 在我的 .m2 目录中有工件的本地测试时,它失败了。很好,我能理解其中一位作者的观点here

我遇到的问题是,当我删除本地存根 jar 和 运行 测试用例时,工件会被下载并再次放入我的 .m2 目录中。实际上,这只允许我 运行 存根 运行ner 一次 ,然后失败,因为我在本地有文件。每次测试 运行.

后,我必须继续从 .m2 中删除工件

我已经通过配置解决了这个问题:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <systemPropertyVariables>
            <maven.repo.local>
                ${project.build.directory}/repo/${maven.build.timestamp}
            </maven.repo.local>
        </systemPropertyVariables>
    </configuration>
</plugin>

这意味着每次存根 运行ner 运行s,它都会检查并下载到一个新的 "random" 目录 /target/repo/<date>.

这样做的正确方法是什么?

当您有共享 .m2 时,此问题可能(并不总是发生)在 CI 系统中。在下一个版本(1.2.x 和 2.0.0)中,由于这个问题 https://github.com/spring-cloud/spring-cloud-contract/issues/545 的关闭,您将能够通过 stubrunner.snapshot-check-skip 系统 属性 或 STUBRUNNER_SNAPSHOT_CHECK_SKIP 环境变量或设置插件 属性(仅适用于 2.0.0)以禁用检查。