如何正确使用maven资源插件

时间:2017-11-03 21:08:10

标签: maven build pom.xml maven-resources-plugin

项目清理并安装时出现构建失败,

我认为构建失败的原因是maven资源插件。

我在构建项目期间遇到了以下错误

[DEBUG] Configuring mojo org.apache.maven.plugins:maven-resources-plugin:2.7:resources from plugin realm ClassRealm[plugin>org.apache.maven.plugins:maven-resources-plugin:2.7, parent: sun.misc.Launcher$AppClassLoader@70dea4e]
[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:2583)
at java.lang.Class.getDeclaredFields (Class.java:1916)
at com.google.inject.spi.InjectionPoint.getInjectionPoints (InjectionPoint.java:675)
at com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields (InjectionPoint.java:380)
at com.google.inject.internal.ConstructorBindingImpl.getInternalDependencies (ConstructorBindingImpl.java:164)
at com.google.inject`enter code here`.internal.InjectorImpl.getInternalDependencies (InjectorImpl.java:613)
at com.google.inject.internal.InjectorImpl.cleanup (InjectorImpl.java:569)

调试时也显示以下错误

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.291 s
[INFO] Finished at: 2017-11-04T02:15:13+05:30
[INFO] Final Memory: 10M/245M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.7:resources (default-resources) on project cas: 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

在pom中使用了maven资源插件

<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>

请帮我解决这个问题,我已经尝试了很多方法来解决这个问题,但仍然无法找到解决方案。

我正在使用以下maven版本

buddika@buddika-pc:~$ mvn -version
Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T13:28:13+05:30)
Maven home: /usr/local/apache-maven/apache-maven-3.5.2
Java version: 1.8.0_73, vendor: Oracle Corporation
Java home: /home/buddika/installs/JDK8/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.4.0-98-generic", arch: "amd64", family: "unix"

谢谢......

1 个答案:

答案 0 :(得分:0)

NoClassDefFoundError:Lorg / sonatype / plexus / build / incremental / BuildContext。意味着没有jar的sonatype ..加上jar并尝试构建.. 记住NoClassDefFoundError意味着你的本地不存在jar ..添加它并尝试..