WireMockEducation:test: 找不到 com.github.JensPiegsa:wiremock-extension:0.4.0

WireMockEducation:test: Could not find com.github.JensPiegsa:wiremock-extension:0.4.0

我尝试将 wiremock 扩展添加到项目中,但是 Gradle 找不到所需的存储库。

https://mvnrepository.com/artifact/com.github.JensPiegsa/wiremock-extension/0.4.0

plugins {
    id "java"
}

....

repositories{
    mavenCentral()
    maven {
        url "https://repository.mulesoft.org/nexus/content/repositories/public/"
    }
}

dependencies {
...
    //wiremock
    testImplementation "com.github.tomakehurst:wiremock-jre8-standalone:2.24.1"
    testImplementation group: 'com.github.JensPiegsa', name: 'wiremock-extension', version: '0.4.0'
}

我收到的错误:

WireMockEducation:test: Could not find com.github.JensPiegsa:wiremock-extension:0.4.0.
Searched in the following locations:
  - https://repo.maven.apache.org/maven2/com/github/JensPiegsa/wiremock-extension/0.4.0/wiremock-extension-0.4.0.pom
  - https://repository.mulesoft.org/nexus/content/repositories/public/com/github/JensPiegsa/wiremock-extension/0.4.0/wiremock-extension-0.4.0.pom

首先,mvnrepository 不是“官方仓库”。相反,它是一个聚合来自多个“真实”maven 存储库的信息的站点,它可能不包含最新信息。

如果你查看实际的 Mulesoft repository,你会发现该模块确实已经不存在了(除了一些元数据):

Index of /repositories/public/com/github/JensPiegsa/wiremock-extension
Name    Last Modified   Size    Description
Parent Directory
maven-metadata.xml.md5  Mon Sep 13 04:55:04 UTC 2021    33  
maven-metadata.xml.sha-256  Mon Sep 13 04:55:04 UTC 2021    65  
maven-metadata.xml.sha-512  Mon Sep 13 04:55:04 UTC 2021    129 
maven-metadata.xml.sha1 Mon Sep 13 04:55:04 UTC 2021    41  

但是从 project documentation 可以看出,您应该使用 Jitpack 存储库而不是 Mulesoft:

repositories { 
     mavenCentral()
     maven { url "https://jitpack.io" }
}
dependencies {
    testImplementation "com.github.tomakehurst:wiremock-jre8-standalone:2.24.1"
    testImplementation "com.github.JensPiegsa:wiremock-extension:0.4.0"
}