`

java.lang.NoClassDefFoundError: org/apache/maven/shared/filtering/MavenFiltering

 
阅读更多

今天通过maven编译项目时,发现org/apache/maven/shared/filtering/MavenFilteringException 不存在。于是找到本地仓库 发现reosurce plugin没有下载下来。于是通过检查pom.xml找到的错误的原因。

 

错误信息:

at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:130)
 ... 21 more
Caused by: java.lang.NoClassDefFoundError: org/apache/maven/shared/filtering/MavenFilteringException
 at java.lang.Class.getDeclaredConstructors0(Native Method)
 at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
 at java.lang.Class.getDeclaredConstructors(Class.java:1836)
 at com.google.inject.spi.InjectionPoint.forConstructorOf(InjectionPoint.java:245)
 at com.google.inject.internal.ConstructorBindingImpl.create(ConstructorBindingImpl.java:99)
 at com.google.inject.internal.InjectorImpl.createUninitializedBinding(InjectorImpl.java:653)
 at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:863)
 at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:790)
 at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:278)
 at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:210)
 at com.google.inject.internal.InjectorImpl.getProviderOrThrow(InjectorImpl.java:986)
 at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:1019)
 at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:982)
 at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1032)
 at org.eclipse.sisu.space.AbstractDeferredClass.get(AbstractDeferredClass.java:48)
 at com.google.inject.Scopes$1$1.get(Scopes.java:59)
 at org.eclipse.sisu.inject.LazyBeanEntry.getValue(LazyBeanEntry.java:82)
 at org.eclipse.sisu.plexus.LazyPlexusBean.getValue(LazyPlexusBean.java:51)
 at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:260)
 at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:252)
 at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:459)
 at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:97)
 ... 21 more
Caused by: java.lang.ClassNotFoundException: org.apache.maven.shared.filtering.MavenFilteringException
 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:242)
 at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:227)
 ... 55 more
[ERROR]

 

解决方案:
1.出现此错误时一定是download resource插件时,maven私服上没有这个版本的插件.现在存在的resource插件版本为2.4.3可以改成这个版本试试.

<plugin>  
    <groupId>org.apache.maven.plugins</groupId>  
    <artifactId>maven-resources-plugin</artifactId>  
    <version>2.4.3</version>  
    <configuration>  
        <encoding>${project.build.sourceEncoding}</encoding>  
    </configuration>  
</plugin>  

 

2.我出现的原因是因为子项目没有引用服务项目的plugin插件导致maven会默认自动下载resource插件 而新版本的resource插件不存在.所以报了如上的错误
解决方案把plugin插件添加到子项目中然后指定插件版本号即可.

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics