gpt4 book ai didi

spring-boot - 该工件在本地存储库中找到,但您已明确声明应从远程存储库下载它”

转载 作者:行者123 更新时间:2023-11-28 21:07:01 25 4
gpt4 key购买 nike

我有一个消费者项目,它有 spring cloud contract tests verifier,它需要与远程 repo 中的 stub jar 对话。 stubsMode: LOCAL 的设置工作正常,但对于远程它会抛出以下错误。

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.contract.stubrunner.BatchStubRunner]: Factory method 'batchStubRunner' threw exception; nested exception is java.lang.IllegalStateException: The artifact was found in the local repository but you have explicitly stated that it should be downloaded from a remote one
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:622)
... 43 more
Caused by: java.lang.IllegalStateException: The artifact was found in the local repository but you have explicitly stated that it should be downloaded from a remote one

消费者端远程代码:

`@RunWith(SpringRunner.class)
@SpringBootTest(classes = RestClientConfig.class,
webEnvironment = SpringBootTest.WebEnvironment.MOCK)
@AutoConfigureStubRunner( repositoryRoot="https://nexus.com/nexus/content/repositories/sam-releases/com/sam/api/",
ids = "com.sam:api:+:stubs:8083",
stubsMode = StubRunnerProperties.StubsMode.REMOTE
)

pom.xml

<spring-cloud.version>Finchley.SR2</spring-cloud.version>
<spring-cloud-contract.version>2.0.2.RELEASE</spring-cloud-contract-version>

我需要为消费者项目使用 REMOTE repoUrl 来与生产者 stub jar 对话。

最佳答案

如果您阅读此部分的文档 https://cloud.spring.io/spring-cloud-static/Finchley.SR2/single/spring-cloud.html#_ci_server_setup (实际上在文档中找到您要查找的异常就足够了)您将看到以下文本:

91.4 CI Server setup

When fetching stubs / contracts in a CI, shared environment, what might happen is that both the producer and the consumer reuse the same local Maven repository. Due to this, the framework, responsible for downloading a stub JAR from remote location, can’t decide which JAR should be picked, local or remote one. That caused the "The artifact was found in the local repository but you have explicitly stated that it should be downloaded from a remote one" exception and failed the build.

For such cases we’re introducing the property and plugin setup mechanism:

via stubrunner.snapshot-check-skip system property
via STUBRUNNER_SNAPSHOT_CHECK_SKIP environment variable

if either of these values is set to true, then the stub downloader will not verify the origin of the downloaded JAR.

For the plugins you need to set the contractsSnapshotCheckSkip property to true.

只需遵循文档中的指南,您就不会再遇到此问题。或者碰上格林威治发布列车,这个问题得到了完全解决。

关于spring-boot - 该工件在本地存储库中找到,但您已明确声明应从远程存储库下载它”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56030148/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com