---
title: 编译spring-cloud-contract-2.2.1.RELEASE源码
description: "鲲鹏镜像站中提供的二进制包是基于开源代码直接编译打包而成的，不含漏洞及BUG修复。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengwebs/ecosystemEnable/SpringCloud/kunpengspringcloudhoxton_02_0027.html
sourcePath: /source/zh/kunpengwebs/ecosystemEnable/SpringCloud/kunpengspringcloudhoxton_02_0027.html
indexId: f429930741bdb2e64e78737dbf7d48d9f4b0fdcba2d8b4a89ac7bdd38d8b15a688
---
# 编译spring-cloud-contract-2.2.1.RELEASE源码

鲲鹏镜像站中提供的二进制包是基于开源代码直接编译打包而成的，不含漏洞及BUG修复。

使用开源软件时需遵守开源软件的许可协议。


1. 下载spring-cloud-contract-2.2.1.RELEASE源码。
  1 2 3 cd /home git config --global http.sslVerify false git clone https://github.com/spring-cloud/spring-cloud-contract.git

2. 切换到指定版本。
  1 2 cd spring-cloud-contract git checkout v2.2.1.RELEASE

3. 替换wiremock-jre8-standalone-2.25.1.jar包。
- 由于wiremock项目中依赖了conscrypt-openjdk-uber-2.1.0.jar，其中缺少适配Arm64架构的SO文件引起了报错，需将本地Maven仓库中wiremock-jre8-standalone-2.25.1.jar替换。
- wiremock-jre8-standalone-2.25.1.jar包可以通过华为鲲鹏镜像站直接下载获取，也可参考《  wiremock-jre8-standalone-2.25.1.jar 移植指南(https://www.hikunpeng.com/document/detail/zh/kunpengwebs/ecosystemEnable/DependencyLibrary/kunpengwiremockstandalone_02_0001.html)
》自行编译得到，本文使用直接从镜像站下载的方法。


  a. 创建库目录“~/.m2/repository/com/github/tomakehurst/wiremock-jre8-standalone/2.25.1/”。
    1 mkdir -p ~/.m2/repository/com/github/tomakehurst/wiremock-jre8-standalone/2.25.1/

  b. 获取wiremock-jre8-standalone-2.25.1.jar包。
    1 wget https://mirrors.huaweicloud.com/kunpeng/maven/com/github/tomakehurst/wiremock-jre8-standalone/2.25.1/wiremock-jre8-standalone-2.25.1.jar --no-check-certificate

  c. 将下载的JAR包复制到库目录下。
    1 cp wiremock-jre8-standalone-2.25.1.jar ~/.m2/repository/com/github/tomakehurst/wiremock-jre8-standalone/2.25.1/

4. 替换hoverfly-junit-0.2.2.jar包。
- 编译过程中会拉取hoverfly-junit-0.2.2.jar，此Jar包中不含有Arm64架构的hoverfly二进制文件，需将本地Maven仓库中的hoverfly-junit-0.2.2.jar进行替换。
- hoverfly-junit-0.2.2.jar包可以通过华为鲲鹏镜像站直接下载获取，也可参考《  hoverfly-junit-0.2.2.jar移植指南(https://www.hikunpeng.com/document/detail/zh/kunpengwebs/ecosystemEnable/DependencyLibrary/kunpenghoverflyjunit_02_0001.html)
》自行编译得到，本文使用直接从镜像站下载的方法。


  a. 创建库目录“~/.m2/repository/io/specto/hoverfly-junit/0.2.2/”。
    1 mkdir -p ~/.m2/repository/io/specto/hoverfly-junit/0.2.2/

  b. 获取hoverfly-junit-0.2.2.jar包。
    1 wget https://mirrors.huaweicloud.com/kunpeng/maven/io/specto/hoverfly-junit/0.2.2/hoverfly-junit-0.2.2.jar --no-check-certificate

  c. 将下载的JAR包复制到库目录下。
    1 cp hoverfly-junit-0.2.2.jar ~/.m2/repository/io/specto/hoverfly-junit/0.2.2/

  d. 查看该JAR文件。

```
jar tvf
~
/.m2/repository/io/specto/hoverfly-junit/0.2.2/hoverfly-junit-0.2.2.jar
```


  e. 将该JAR包解压到指定目录。

```
unzip
~
/.m2/repository/io/specto/hoverfly-junit/0.2.2/hoverfly-junit-0.2.2.jar -d
~
/.m2/repository/io/specto/hoverfly-junit/0.2.2/hoverfly-junit-0.2.2
```


  f. 切换到解压后的目录，同时将hoverfly_v0.9.1_linux_arm64重命名为hoverfly_v0.9.1_linux_amd64。

```
cd
~
/.m2/repository/io/specto/hoverfly-junit/0.2.2/hoverfly-junit-0.2.2 && mv hoverfly_v0.9.1_linux_arm64 hoverfly_v0.9.1_linux_amd64
```


  g. 将当前目录中的所有文件打包为新的JAR包。

```
jar cvf ../hoverfly-junit-0.2.2.jar -c ./*
```


5. 执行编译。
  1 2 cd /home/spring-cloud-contract ./mvnw clean install -Dgpg.skip=true

  若显示BUILD SUCCESS，则编译通过。

  如果编译时遇到spring-cloud-contract-stub-runner报错，可以参考问题现象描述进行修改。 如果编译遇到错误信息“Failed during checkstyle execution”，参考编译Spring Boot时提示Failed during checkstyle execution的解决方法解决。 如果编译环境需要借助代理访问互联网，可以参考结论、解决方案及效果进行配置，否则Spring-Cloud-Contract-Gradle-Plugin可能报错。
