Spring Cloud Contract 从 Artifactory 检索存根时出现问题

2024-01-16

我对两个消费者和一个生产者进行了离线工作正常的测试,但是当我更改它们以从 Artifactory 检索存根时,消费者测试失败。

这是离线工作的代码:

@RunWith(SpringRunner.class)
@SpringBootTest(classes = ContractTestConfiguration.class, webEnvironment = SpringBootTest.WebEnvironment.NONE)
@AutoConfigureStubRunner(ids = {"com.mycompany:service-name:+:stubs"}, workOffline = true)
@ImportAutoConfiguration(org.springframework.cloud.stream.test.binder.TestSupportBinderAutoConfiguration.class)
@DirtiesContext
public class MyContractTest

这是在线的:

@RunWith(SpringRunner.class)
@SpringBootTest(classes = ContractTestConfiguration.class, webEnvironment = SpringBootTest.WebEnvironment.NONE)
@AutoConfigureStubRunner(ids = {"com.mycompany:service-name:+:stubs"}, repositoryRoot = "https://artifactory.companyname.com/artifactory/artifacts-snapshot-local")
@ImportAutoConfiguration(org.springframework.cloud.stream.test.binder.TestSupportBinderAutoConfiguration.class)
@DirtiesContext
public class MyContractTest {

我收到此错误:

Exception occurred while trying to download a stub for group [com.mycompany] module [service-name] and classifier [stubs] in [remote0 (https://artifactory.mycompany.com/artifactory/artifacts-snapshot-local, default, releases+snapshots)]
org.eclipse.aether.resolution.ArtifactResolutionException: Could not find artifact com.mycompany.domain:service-name:jar:stubs:1.6.0-SNAPSHOT

我看过 Artifactory 和https://artifactory.mycompany.com/artifactory/artifacts-snapshot-local https://artifactory.mycompany.com/artifactory/artifacts-snapshot-local存根罐子出现在那里。我已经完成了生产者的 mvn 安装,当我再次运行测试时,我收到此错误“该工件在本地存储库中找到,但您已明确指出应该从远程存储库下载它”。

我还尝试向消费者添加对生产者存根的依赖,但我遇到了类似的错误。我宁愿避免它,因为它会添加与生产者的特定版本的依赖关系:

<dependency>
    <groupId>com.companyname</groupId>
    <artifactId>service-name</artifactId>
    <classifier>stubs</classifier>
    <version>1.6.0-SNAPSHOT</version>
    <scope>test</scope>
    <exclusions>
        <exclusion>
            <groupId>*</groupId>
            <artifactId>*</artifactId>
        </exclusion>
    </exclusions>
</dependency>

我已将其添加到生产者的 POM 文件中:

<spring.cloud.contract.verifier.skip>true</spring.cloud.contract.verifier.skip>

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-assembly-plugin</artifactId>
    <executions>
        <execution>
            <id>stub</id>
            <goals>
                <goal>single</goal>
            </goals>
            <phase>prepare-package</phase>
            <inherited>false</inherited>
            <configuration>
                <attach>true</attach>
                <descriptor>${basedir}/src/assembly/stub.xml</descriptor>
            </configuration>
        </execution>
    </executions>
</plugin>

这是 src/Assembly 下文件 Stub.xml 的内容:

<assembly
        xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
    <id>stubs</id>
    <formats>
        <format>jar</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <fileSets>
        <fileSet>
            <directory>src/main/java</directory>
            <outputDirectory>/</outputDirectory>
            <includes>
                <include>**com/companyname/projectname/*.*</include>
            </includes>
        </fileSet>
        <fileSet>
            <directory>${project.build.directory}/classes</directory>
            <outputDirectory>/</outputDirectory>
            <includes>
                <include>**com/companyname/projectname/*.*</include>
            </includes>
        </fileSet>
        <fileSet>
            <directory>${project.build.directory}/snippets/stubs</directory>
            <outputDirectory>META-INF/${project.groupId}/${project.artifactId}/${project.version}/mappings</outputDirectory>
            <includes>
                <include>**/*</include>
            </includes>
        </fileSet>
        <fileSet>
            <directory>${basedir}/src/test/resources/contracts</directory>
            <outputDirectory>META-INF/${project.groupId}/${project.artifactId}/${project.version}/contracts</outputDirectory>
            <includes>
                <include>**/*.groovy</include>
            </includes>
        </fileSet>
    </fileSets>
</assembly>

知道我缺少什么吗?提前致谢


我看过 Artifactory 和https://artifactory.mycompany.com/artifactory/artifacts-snapshot-local https://artifactory.mycompany.com/artifactory/artifacts-snapshot-local存根罐子出现在那里。我已经完成了生产者的 mvn 安装,当我再次运行测试时,我收到此错误“该工件在本地存储库中找到,但您已明确指出应该从远程存储库下载它”。

当您在本地安装存根,然后尝试从神器下载它时,会发生这种情况,但 SHA 不同,因此 Aether(下载存根的引擎)会选择本地存根。在这种情况下,我们会抛出一个异常,因为您想要从远程位置下载存根,而不是从本地获取它。

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

这看起来像在 Artifactory 中,您在某些 Maven 元数据中拥有最新 jar 的条目1.6.0-SNAPSHOT但 JAR 已经不存在了。你能仔细检查一下它是否真的在那里吗?

我还尝试向消费者添加对生产者存根的依赖,但我遇到了类似的错误。我宁愿避免它,因为它会添加与生产者的特定版本的依赖关系:

这只能证明您的工件/项目设置有些混乱。如果您硬编码版本,事情仍然不起作用吗?

UPDATE:

如果您的工件实例需要凭据或位于代理后面,您可以使用这些值:

https://github.com/spring-cloud/spring-cloud-contract/blob/v1.1.4.RELEASE/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/ Stubrunner/spring/StubRunnerProperties.java#L72-L87 https://github.com/spring-cloud/spring-cloud-contract/blob/v1.1.4.RELEASE/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/spring/StubRunnerProperties.java#L72-L87

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

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Spring Cloud Contract 从 Artifactory 检索存根时出现问题 的相关文章

随机推荐

  • 如何使用此 StackPanel 作为资源

    我只是想将 StackPanel 内容放入 ResourceDictionary 中 我尝试将其包装到数据模板中 但没有成功 其他类型的模板 一种风格 如何将其提取到资源中 然后在视图的网格布局中使用内容 Cheers Berryl 要移动
  • 从 Python 创建 Excel XML 文件

    我需要从 Python 创建 Excel XML 文件 Excel XML 格式相当简单 我查看了从 Excel 2003 保存的示例 xml 文件 它相当简单 我正在寻找一个 Pythonic 的现成库来创建此类 xml 文件 而不是重新
  • 相位展开问题(相位展开不正确)?

    我对随着时间的推移展开阶段有一个问题 I have a radar which monitors a slow periodic moving object From the received signal i want to see th
  • 上传符号文件中的 Xcode 错误

    我已遵循 Firebase 崩溃报告集成的正确步骤 但仍然有这样的错误 用户 satish Desktop firebase crash Pods FirebaseCrash upload sym 174 错误 请确保您已按照以下步骤操作
  • 使http客户端同步:等待响应

    我有一些文件要上传 但有些文件失败 因为帖子是异步的而不是同步的 我正在尝试将此呼叫作为同步呼叫 我想等待回复 我怎样才能使这个调用同步 static async Task
  • Visual Studio Online 构建失败 - 本地工作

    我升级到VS2015 MVC更新到5 0 我能够在本地 PC 上成功构建 但是当我签入 Visual Studio Online 并进行 CI 构建时 它失败了 命名空间 System Web 中不存在类型或命名空间名称 Mvc 您是否缺少
  • Tomcat:如何在Java中获取安全端口号?

    我想在我的一个不安全页面中嵌入一个指向我的应用程序安全页面的链接 安全 tomcat 端口在 server xml 文件中配置 在某些部署中 它是 443 8443 等 所以我需要的是一种从 tomcat 配置读取安全端口以在链接中使用它的
  • iOS7 状态栏就像原生天气应用程序

    有谁知道如何从原生 iOS7 天气应用程序中重现类似的效果 基本上 状态栏继承了下面视图的背景 但内容不显示 此外 仅当某些内容位于下方时 才会在状态栏 20 像素高度之后绘制 1 像素线 最好的办法是通过视图的clipSubview来实现
  • 如何在 lldb 中实时运行脚本上转储 PHP 回溯?

    我正在玩LLDB 调试器 https en wikipedia org wiki LLDB debugger 我做了以下实验 运行 PHP 脚本 php r sleep 1000 or php r function r sleep 1000
  • 如何更改 Glassfish 的默认起始页?

    目前 当我输入 web 应用程序的 URL 例如 http abc edu mywebapp 时 我会进入 web 应用程序的登录页面 当我输入 http abc edu 时 我会进入 GlassFish 信息页面 我怎样才能做到这一点 当
  • WSL 上的 Docker 不会绑定挂载 $HOME

    我在 WSL Linux 的 Windows 子系统 Ubuntu 16 04 上使用 Docker 时遇到了最奇怪的情况 我正在尝试绑定挂载 home username 要不就 HOME为了方便起见 作为容器中的卷 并且我没有在容器中查找
  • error.add_to_base 的 Rails3 版本是什么?

    我想在 Rails 3 中编写自定义验证 但是以下这个例子 http paulsturgess co uk articles show 33 how to write custom validation in ruby on rails I
  • 如何修复 FilePond 拖放中的“未捕获的引用错误:FilePond 未定义”

    我正在尝试使用 FilePond 在我的网站上实现拖放功能 我已经下载了 filepond css 和 js 文件并正确附加它们 每当我尝试完成设置时 我都会收到 未捕获的引用错误 FilePond 未定义 的消息 extends main
  • 更改正在运行的系统上的 Vagrant 端口转发

    我有一个 Vagrant 系统正在运行 我想对其进行更改 只需更改其中一个转发规则即可 From 这一页 http vagrantup com docs getting started ports html 转发端口在期间应用vagrant
  • Java 8 中的新 java.security.AccessControlException

    以前工作的网络代码正在抛出java security AccessControlException在完全沙盒的 Java 中applet Can t get socket 2255 java security AccessControlEx
  • “您尝试通过调用 firebase.app() 来使用 Android 项目上未安装的 Firebase 模块。”

    我跟着https rnfirebase io management workflow https rnfirebase io managed workflow有关如何安装 Firebase 的指南 我创建了一个新的 Expo 应用程序 np
  • 如何设置 Apache 返回 204 代码?

    如何设置 Apache 对某个 URL 返回 204 无内容 而不是 404 代码 将 Redirect 文档与 RedirectMatch 文档放在一起 我们发现是的 我们可以发回自定义 204 下面是一个简单的示例 它对任何与 foo
  • 错误“在 Visual Studio 中找不到元数据文件 '...\Release\project.dll'”

    最近我开始随机收到此消息 在 Visual Studio 中找不到元数据文件 Release project dll 我有一个包含多个项目的解决方案 当前的构建模式是 调试 并且所有项目的配置都设置为 调试 但是当我尝试运行主项目时 有时它
  • 基于maven配置文件的黄瓜标签

    我正在尝试基于变量 tags 运行特定的 Gherkin 场景 如果可能的话 例如 如果我的配置文件是 dev 我想运行场景 1 如果配置文件是 qa 我想运行场景 2 我可以在我的 java 类中获取配置文件值 我还可以在命令行中传递标签
  • Spring Cloud Contract 从 Artifactory 检索存根时出现问题

    我对两个消费者和一个生产者进行了离线工作正常的测试 但是当我更改它们以从 Artifactory 检索存根时 消费者测试失败 这是离线工作的代码 RunWith SpringRunner class SpringBootTest class