我有消费者项目,它有弹簧云合同测试验证器,它需要与远程仓库中的存根 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 让消费者项目与生产者存根 jar 对话。