Spring Cloud Contract无法从Nexus,存根模式(Stub Mode)远程查找/下载工件

时间:2019-01-04 17:25:03

标签: spring-cloud-contract

从消费者的角度来看,我试图将带有存根模式的Nexus存储库称为REMOTE,但是我遇到错误,下载存根时找不到工件或异常。

有人可以帮我吗?

@AutoConfigureStubRunner(ids = "com.common.service:Common-Service-STUB:1.0.0-SNAPSHOT", stubsMode = StubRunnerProperties.StubsMode.REMOTE, repositoryRoot = "https://nexus.prod.cloud.XXX.com:8443/nexus/content/repositories/XXX-snapshot", stubsPerConsumer = true)

存储库结构

com
 - common
 - - service
 - - - Common-Service
 - - - Common-Service-STUB
 - - - - 1.0.0-Timestamp
 - - - - - Common-Service-STUB-1.0.0-Timestamp.jar
 - - - - 1.0.0-SNAPSHOT
 - - - - - maven-metadata.xml (this has the most recent Timestamp)

异常Stacktrace

Caused by: java.lang.IllegalStateException: Exception occurred while trying to download a stub for group [com.common.service] module [Common-Service-STUB] and classifier [stubs] in [remote0 (Valid Nexus-Repo-snapshot)]
    at org.springframework.cloud.contract.stubrunner.AetherStubDownloader.unpackedJar(AetherStubDownloader.java:184)
    at org.springframework.cloud.contract.stubrunner.AetherStubDownloader.downloadAndUnpackStubJar(AetherStubDownloader.java:222)
    at org.springframework.cloud.contract.stubrunner.CompositeStubDownloader.downloadAndUnpackStubJar(CompositeStubDownloaderBuilder.java:77)
    at org.springframework.cloud.contract.stubrunner.StubRunnerFactory.createStubsFromServiceConfiguration(StubRunnerFactory.java:60)
    at org.springframework.cloud.contract.stubrunner.BatchStubRunnerFactory.buildBatchStubRunner(BatchStubRunnerFactory.java:59)
    at org.springframework.cloud.contract.stubrunner.spring.StubRunnerConfiguration.batchStubRunner(StubRunnerConfiguration.java:78)
    at org.springframework.cloud.contract.stubrunner.spring.StubRunnerConfiguration$$EnhancerBySpringCGLIB$$c9316bb9.CGLIB$batchStubRunner$0(<generated>)
    at org.springframework.cloud.contract.stubrunner.spring.StubRunnerConfiguration$$EnhancerBySpringCGLIB$$c9316bb9$$FastClassBySpringCGLIB$$b60005.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361)
    at org.springframework.cloud.contract.stubrunner.spring.StubRunnerConfiguration$$EnhancerBySpringCGLIB$$c9316bb9.batchStubRunner(<generated>)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
    ... 67 more
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not find artifact com.common.service:Common-Service-STUB:jar:stubs:1.0.0-SNAPSHOT in remote0 (Valid Nexus-Repo-snapshot)
    at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:444)
    at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:246)
    at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:223)
    at shaded.org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:294)
    at org.springframework.cloud.contract.stubrunner.AetherStubDownloader.unpackedJar(AetherStubDownloader.java:168)
    ... 82 more
Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact com.common.service:Common-Service-STUB:jar:stubs:1.0.0-SNAPSHOT in remote0 (Valid Nexus-Repo-snapshot)
    at shaded.org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:39)
    at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:355)
    at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:67)
    at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:581)
    at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:249)
    at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:520)
    at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:421)
    ... 86 more

1 个答案:

答案 0 :(得分:0)

让我们看看您在注释中写的内容。 com.common.service:Common-Service-STUB:1.0.0-SNAPSHOT。这意味着您的组ID为com.common.service,工件ID为​​common-service-stub,版本为1.0.0-SNAPSHOT。另外,默认分类器为stub。因此,您正在寻找带有Common-Service-STUB分类器的工件stub。换句话说,搜索Common-Service-STUB-stub.jar。将com.common.service:Common-Service-STUB:1.0.0-SNAPSHOT更改为com.common.service:Common-Service:1.0.0-SNAPSHOT