gpt4 book ai didi

java - Maven 依赖插件似乎无法解决所有依赖

转载 作者:行者123 更新时间:2023-12-04 12:04:06 27 4
gpt4 key购买 nike

我创建了一个非常简单的 Maven 项目来构建一个 .war 文件。 Maven 版本 3.2.3,Java 版本 1.7.0_67。 pom.xml 文件在这个 gist 中.

如果我运行 mvn clean install ,然后项目构建良好。但是如果我首先使用 mvn dependency:resolve 下载所有依赖项和 mvn dependency:resolve-plugins ,然后运行 ​​mvn -o install要离线构建,我收到如下错误。

[INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ docker-restaesy-1 ---
[WARNING] The POM for org.apache.maven:maven-plugin-api:jar:2.2.1 is missing, no dependency information available
[WARNING] The POM for org.apache.maven:maven-project:jar:2.2.1 is missing, no dependency information available
[WARNING] The POM for org.apache.maven:maven-core:jar:2.2.1 is missing, no dependency information available
[WARNING] The POM for org.apache.maven:maven-artifact:jar:2.2.1 is missing, no dependency information available
[WARNING] The POM for org.apache.maven:maven-settings:jar:2.2.1 is missing, no dependency information available
[WARNING] The POM for org.apache.maven:maven-model:jar:2.2.1 is missing, no dependency information available
[WARNING] The POM for org.apache.maven:maven-monitor:jar:2.2.1 is missing, no dependency information available
[WARNING] The POM for org.codehaus.plexus:plexus-utils:jar:3.0.15 is missing, no dependency information available
[WARNING] The POM for org.apache.maven.shared:maven-filtering:jar:1.2 is missing, no dependency information available
[WARNING] The POM for org.codehaus.plexus:plexus-interpolation:jar:1.19 is missing, no dependency information available
[WARNING] Error injecting: org.apache.maven.shared.filtering.DefaultMavenResourcesFiltering
java.lang.NoClassDefFoundError: Lorg/sonatype/plexus/build/incremental/BuildContext;
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2436)
at java.lang.Class.getDeclaredFields(Class.java:1806)
at com.google.inject.spi.InjectionPoint.getInjectionPoints(InjectionPoint.java:661)
at com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields(InjectionPoint.java:366)
at com.google.inject.internal.ConstructorBindingImpl.getInternalDependencies(ConstructorBindingImpl.java:165)
at com.google.inject.internal.InjectorImpl.getInternalDependencies(InjectorImpl.java:609)
at com.google.inject.internal.InjectorImpl.cleanup(InjectorImpl.java:565)
...
Caused by: java.lang.ClassNotFoundException: org.sonatype.plexus.build.incremental.BuildContext
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:259)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:235)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:227)
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.544 s
[INFO] Finished at: 2014-12-09T23:24:57+00:00
[INFO] Final Memory: 9M/303M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.7:resources (default-resources) on project docker-restaesy-1: Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:2.7:resources failed: A required class was missing while executing org.apache.maven.plugins:maven-resources-plugin:2.7:resources: Lorg/sonatype/plexus/build/incremental/BuildContext;
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.apache.maven.plugins:maven-resources-plugin:2.7
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/root/.m2/repository/org/apache/maven/plugins/maven-resources-plugin/2.7/maven-resources-plugin-2.7.jar
[ERROR] urls[1] = file:/root/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.15/plexus-utils-3.0.15.jar
[ERROR] urls[2] = file:/root/.m2/repository/org/apache/maven/shared/maven-filtering/1.2/maven-filtering-1.2.jar
[ERROR] urls[3] = file:/root/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.19/plexus-interpolation-1.19.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]

我比较了通过两种方式创建的 .m2/repository 文件夹,使用依赖插件创建的一种缺少许多文件,其中大部分与 plexus 相关。

那么为什么依赖插件不解析所有的依赖呢?我在这里做错了吗?谢谢

编辑
我在 mvn dependency:go-offline 上遇到了同样的错误

最佳答案

我知道这为时已晚,但如果对某人有帮助,请发布此答案。
java.lang.ClassNotFoundException: 显然意味着 org.sonatype.plexus.build.incremental.BuildContext 的 jar 是

  • 不可用
  • 可用但路径错误
  • jar 已损坏

  • 负责这个类的jar是plexus-build-api-0.0.4.jar
    检查您的构建输出并查看 mvn 正在寻找此 jar 的路径。
    例如,我的输出中有以下行
    /Users/akash/.m2/repository/org/sonatype/plexus/plexus-build-api/0.0.4/
    在我的情况下,jar plexus-build-api-0.0.4.jar 在此路径中已损坏。
    我检查了 $jar -tbv ,它不返回类名,然后它已损坏
    我是从 link 下载的并为我工作。
    在您的情况下,您没有此路径,因此您必须重新创建项目/重新安装插件。
    您也可以尝试手动创建此路径,从链接 link 下载 jars看看它是否有效。

    关于java - Maven 依赖插件似乎无法解决所有依赖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27391007/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com