Maven构建失败--DependencyResolutionException

Maven构建失败--DependencyResolutionException,maven,pom.xml,dependency-resolution,Maven,Pom.xml,Dependency Resolution,我正在安装一个具有Maven依赖项的包,当我尝试清理它时,会得到一个DependencyResolutionException。 克隆后,我导航到该目录并运行以下操作以安装它,不会出现错误: mvn install:install-file -Dfile=./lib/massbank.jar -DgroupId=massbank -DartifactId=massbank -Dversion=1.0 -Dpackaging=jar mvn install:install-file -Dfile

我正在安装一个具有Maven依赖项的包,当我尝试清理它时,会得到一个DependencyResolutionException。 克隆后,我导航到该目录并运行以下操作以安装它,不会出现错误:

mvn install:install-file -Dfile=./lib/massbank.jar -DgroupId=massbank  -DartifactId=massbank -Dversion=1.0 -Dpackaging=jar
mvn install:install-file -Dfile=./lib/metfusion.jar -DgroupId=de.ipbhalle.msbi  -DartifactId=metfusion -Dversion=1.0 -Dpackaging=jar
然后:

具有以下控制台输出:

[INFO] Scanning for projects...
[INFO] 
[INFO] --------------------< MassBank2NIST:MassBank2NIST >---------------------
[INFO] Building MassBank2NIST 0.0.2-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.450 s
[INFO] Finished at: 2021-04-07T01:08:28-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project MassBank2NIST: Could not resolve dependencies for project MassBank2NIST:MassBank2NIST:jar:0.0.2-SNAPSHOT: Failed to collect dependencies at edu.ucdavis.fiehnlab.splash:core:jar:1.8: Failed to read artifact descriptor for edu.ucdavis.fiehnlab.splash:core:jar:1.8: Could not transfer artifact edu.ucdavis.fiehnlab.splash:core:pom:1.8 from/to maven-default-http-blocker (http://0.0.0.0/): Blocked mirror for repositories: [EBI (http://www.ebi.ac.uk/intact/maven/nexus/content/repositories/ebi-repo/, default, releases+snapshots), releases (http://gose.fiehnlab.ucdavis.edu:55000/content/groups/public, default, releases+snapshots)] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
[INFO]正在扫描项目。。。
[信息]
[信息]-----------------------------------
[信息]建设Massbank2List 0.0.2-SNAPSHOT
[信息]------------------------------------[jar]---------------------------------
[信息]------------------------------------------------------------------------
[信息]生成失败
[信息]------------------------------------------------------------------------
[信息]总时间:0.450秒
[信息]完成时间:2021-04-07T01:08:28-04:00
[信息]------------------------------------------------------------------------
[错误]未能在项目MassBank2List上执行目标:无法解析项目MassBank2List:MassBank2List:jar:0.0.2-SNAPSHOT:未能在edu.ucdavis.fiehnlab收集依赖项。splash:core:jar:1.8:未能读取edu.ucdavis.fiehnlab的工件描述符。splash:core:jar:1.8:无法传输工件splash:core:pom:1.8 from/to maven默认http阻止程序(http://0.0.0.0/):已阻止存储库的镜像:[EBI](http://www.ebi.ac.uk/intact/maven/nexus/content/repositories/ebi-repo/,默认值,发布+快照),发布(http://gose.fiehnlab.ucdavis.edu:55000/content/groups/public,默认,发布+快照)]->[帮助1]
[错误]
[错误]要查看错误的完整堆栈跟踪,请使用-e开关重新运行Maven。
[错误]使用-X开关重新运行Maven以启用完整调试日志记录。
[错误]
[错误]有关错误和可能的解决方案的更多信息,请阅读以下文章:
[错误][帮助1]http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
如果有必要,我可以发布调试日志开关的输出,但它相当长。我也可以发布pom.xml,但是根据我所知,它根据需要引用了存储库

我搜索过类似的帖子,但似乎没有一篇包含相同系列的错误或类似内容。有人能帮我破译这些错误吗

谢谢

错误“存储库阻塞镜像”在Maven的:

当HTTP存储库被阻止时如何修复?

如果存储库是在pom.xml中定义的,请在源代码中修复它

如果在您的一个依赖项POM中定义了存储库,您将收到如下消息:

[ERROR] Failed to execute goal on project test: Could not resolve dependencies for project xxx: Failed to collect dependencies at my.test:dependency:version -> my.test.transitive:transitive:version: Failed to read artifact descriptor for my.test.transitive:transitive:jar:version: Could not transfer artifact my.test.transitive:transitive:pom:version from/to maven-default-http-blocker (http://0.0.0.0/): Blocked mirror for repositories: [blocked-repository-id (http://blocked.repository.org, default, releases+snapshots)]
他们还提供了一些避免问题的方法:

要修复的选项有:

  • 将依赖项版本升级到更新版本,将过时的HTTP存储库URL替换为HTTPS URL

  • 保留依赖项版本,但在设置中定义镜像


另外,我想,更简单、更短期的选择是将Maven版本回滚到3.8.1之前的版本。

使用apache-Maven-3.6.3,它只使用http


你不必降级Maven。这里发生的事情是,自3.8.1以来,Maven提供了一个默认配置来阻止所有HTTP(不安全)存储库。最好的方法是升级存储库并使其安全(HTTPS)

但是,通过将此镜像添加到
~/.m2/settings.xml
,您可以告诉Maven允许从不安全的存储库下载:


不安全回购
外部:http:*
http://www.ebi.ac.uk/intact/maven/nexus/content/repositories/ebi-repo/
假的
blocked
设置为
false
将解决您的问题。请注意,上面的代码片段假设位于
www.ebi.ac.uk
的存储库镜像了所有不安全的HTTP存储库(这就是
external:HTTP:
的意思)

您还可以取消阻止单个存储库。例如,JasperSoft存储库不安全,我使用以下方法解除阻止:

<mirror>
  <id>jaspersoft-third-party-mirror</id>
  <mirrorOf>jaspersoft-third-party</mirrorOf>
  <url>http://jaspersoft.jfrog.io/jaspersoft/third-party-ce-artifacts/</url>
  <blocked>false</blocked>
</mirror>

jaspersoft第三方镜像
jaspersoft第三方
http://jaspersoft.jfrog.io/jaspersoft/third-party-ce-artifacts/
假的

使用apache-maven-3.8.1,在
~/.m2/settings.xml
中添加以下内容可以解决此类问题:

<mirrors>
  <mirror>
  <id>internal-repository</id>
  <name>Maven Repository Manager running on https://repo1.maven.org/maven2</name>
  <url>https://repo1.maven.org/maven2</url>
  <mirrorOf>*</mirrorOf>
</mirror>

内部存储库
在上运行的Maven存储库管理器https://repo1.maven.org/maven2
https://repo1.maven.org/maven2
*

请参阅此链接,了解发生错误的原因。

如果您由于构建由cloud CI/CD处理或希望与团队成员共享此解决方案而无法访问
~/.m2/settings.xml
。最好的方法是在项目中创建自己的maven设置文件

  • 在项目中创建
    .mvn
    文件夹
  • 使用此类内容在
    .mvn
    文件夹中创建
    自定义设置.xml
    文件(在本例中,我们为
    releases.java.net
    mirror解除http连接):

  • 您只需运行
    mvn clean install--settings.mvn/custom settings.xml
    打开文件/usr/local/ceral/maven/{maven_version}/libexec/conf/settings.xml

    并对这些行进行注释

    <mirror>
        <id>maven-default-http-blocker</id>
        <mirrorOf>external:http:*</mirrorOf>
        <name>Pseudo repository to mirror external repositories initially using HTTP.</name>
        <url>http://0.0.0.0/</url>
        <blocked>false</blocked>
    </mirror>
    
    
    maven默认http阻止程序
    外部:http:*
    Pseudo repository最初使用HTTP镜像外部存储库。
    http://0.0.0.0/
    假的
    
    apache-maven-3.6.3-bin将解决maven默认http阻止程序(http//0.0.0/)被阻止的问题(对我来说已修复)。它对我有效。

    更新了我的答案,并说明了如何取消阻止单个存储库。谢谢-我意识到我将我的
    声明放在配置文件中,如果我得到两个不同的repository作为repo1和repo2,然后分别为这两个repo创建两个镜像,如下所示,但我仍然得到错误消息。repo1镜像repo1 xx/false repo2镜像repo2 xxyyy/false感谢您的快速回复
    <settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 http://maven.apache.org/xsd/settings-1.2.0.xsd">
        <mirrors>
            <mirror>
                <id>releases-java-net-http-unblocker</id>
                <mirrorOf>releases.java.net</mirrorOf>
                <name>releases.java.net</name>
                <url>http://maven.java.net/content/repositories/releases/</url>
                <blocked>false</blocked>
            </mirror>
        </mirrors>
    </settings>
    
    --settings ./.mvn/custom-settings.xml
    
    <mirror>
        <id>maven-default-http-blocker</id>
        <mirrorOf>external:http:*</mirrorOf>
        <name>Pseudo repository to mirror external repositories initially using HTTP.</name>
        <url>http://0.0.0.0/</url>
        <blocked>false</blocked>
    </mirror>