Spring cloud SpringCloudContract问题从工件中检索存根

Spring cloud SpringCloudContract问题从工件中检索存根,spring-cloud,spring-cloud-contract,Spring Cloud,Spring Cloud Contract,我对两个消费者和一个生产者进行了测试,但当我更改它们以从Artifactory检索存根时,消费者测试失败了 以下是脱机工作的代码: @RunWith(SpringRunner.class) @SpringBootTest(classes=ContractTestConfiguration.class,webEnvironment=SpringBootTest.webEnvironment.NONE) @AutoConfigureSubrunner(ids={“com.mycompany:serv

我对两个消费者和一个生产者进行了测试,但当我更改它们以从Artifactory检索存根时,消费者测试失败了

以下是脱机工作的代码:

@RunWith(SpringRunner.class)
@SpringBootTest(classes=ContractTestConfiguration.class,webEnvironment=SpringBootTest.webEnvironment.NONE)
@AutoConfigureSubrunner(ids={“com.mycompany:service name:+:stubs”},workOffline=true)
@导入配置(org.springframework.cloud.stream.test.binder.TestSupportBinderAutoConfiguration.class)
@肮脏的环境
公共类支原体试验
这是在线的:

@RunWith(SpringRunner.class)
@SpringBootTest(classes=ContractTestConfiguration.class,webEnvironment=SpringBootTest.webEnvironment.NONE)
@AutoConfigureSubrunner(ids={“com.mycompany:service name:+:stubs”},repositoryRoot=”https://artifactory.companyname.com/artifactory/artifacts-snapshot-local")
@导入配置(org.springframework.cloud.stream.test.binder.TestSupportBinderAutoConfiguration.class)
@肮脏的环境
公共类支原体试验{
我得到这个错误:

尝试下载[remote0]中组[com.mycompany]模块[service name]和分类器[stubs]的存根时发生异常(https://artifactory.mycompany.com/artifactory/artifacts-snapshot-local,默认值,发布+快照)]
org.eclipse.aether.resolution.ArtifactResolutionException:找不到artifact com.mycompany.domain:服务名称:jar:存根:1.6.0-SNAPSHOT
我已经在Artifactory和中查看了,stubs jar出现在那里。我已经完成了producer的mvn安装,当我再次运行测试时,我得到了这个错误“该工件在本地存储库中找到,但您明确声明它应该从远程存储库下载”

当您在本地安装存根,然后尝试从artifactory下载它时会发生这种情况,但SHA不同,因此以太(下载存根的引擎)会选择本地存根。在这种情况下,我们抛出异常,因为您希望从远程位置下载存根,而不是从本地位置下载存根

尝试下载组[com.mycompany]模块[service name]和分类器[stubs]在[remote0(,默认,releases+snapshots]中的存根时发生异常 org.eclipse.aether.resolution.ArtifactResolutionException:找不到工件com.mycompany.domain:服务名称:jar:存根:1.6.0-SNAPSHOT

这看起来像是在Artifactory中,您在一些Maven元数据中有一个条目,即最新的jar是
1.6.0-SNAPSHOT
,但jar已经不在了。您可以再次检查它是否确实在那里吗

我也尝试过向消费者添加对制作人存根的依赖,但我得到了类似的错误。我更愿意避免它,因为它会添加对制作人特定版本的依赖:

这只能证明您的工件/项目设置有问题。如果您硬编码版本,事情是否仍然不起作用

更新:

如果您的artifactory实例需要凭据或位于代理之后,则可以使用以下值:


您可以提供
stubrunner.username
stubrunner.password
stubrunner.proxyHost
stubrunner.proxyPort

 @RunWith(SpringRunner.class)
 @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE)
 @AutoConfigureStubRunner(ids = "com.mycompany.myproj:myservice:+:stubs:8100",
    repositoryRoot = "http://artifactory.mycompany.com/artifactory/libs-snapshot-local",
    properties = {"stubrunner.username=myusername", "stubrunner.password=mypassword"},
    stubsMode = StubRunnerProperties.StubsMode.REMOTE)
 @DirtiesContext
 class MyApiContractsVerificationTest {
     ...
 }
凭据正确,存根正确生成并部署到远程Artifactory存储库中。如果我将它们配置为在本地.m2/存储库中查找(删除“repositoryRoot”和“properties”注释参数),测试运行良好,但使用上述配置,我会得到以下错误:

Could not find metadata com.mycommany.myproject:myservice/maven-metadata.xml in local (/Users/myname/.m2/repository), 
org.eclipse.aether.transfer.MetadataTransferException: Could not transfer metadata com.mycommany.myproject:myservice/maven-metadata.xml from/to remote0 (http://artifactory.mycompany.com/artifactory/libs-snapshot-local): **Unauthorized (401)**]
...
在启用远程模式运行测试之前,我确实清理了本地.m2/存储库中的存根,因此没有冲突


我是否提供了错误的用户名和密码?配置中是否有错误或缺失?

感谢您这么快的回复。为了确保我在以前的测试中没有遇到问题,我已从Artifactory中删除了存根jar,进行了另一次mvn部署,并检查了新jar是否已在Artifactory.Aft中发布呃,我已经删除了本地Maven存储库的存根jar,并再次尝试运行使用者测试。我现在有一个不同的错误,“无法将工件com.companyname:service name:jar:stubs:1.6.0-SNAPSHOT从/传输到remote0():connect超时。可能是因为Aether无法下载stubs jar,因为我必须在某处指定Artifactory的用户名和密码?或者可能是代理阻止了对它的访问?我假设Aether使用文件.m2/settings.xml的值,但我将在硬编码值并执行Mav时查找有关它的信息en->Reimport from Intellij,stub从Artifactory下载,当我运行测试时,我在日志中得到这个错误:“该工件在本地存储库中找到,但您明确声明它应该从远程存储库下载”。但是,如果我只是在没有重新导入的情况下运行测试,我会得到一个连接超时,就像我没有对值进行编码一样。我已经用用户名/密码和代理更新了答案。设置Hi,您是否也尝试过配置stubrunner.proxyHost和stubrunner.proxyPort?部署到Artifactory并从中读取是不同的,因为第一个是由Maven使用.m2/settings.xml的值完成的,第二个是由Aether使用您在code@rafaborrego:谢谢您的回复。我不认为我们的工件配置了代理。我希望错误消息更详细一点,提供更多的上下文。呃…当我逐步通过Aethe时我在调试器中看到了rStubDownloader代码