eclipse pom.xml 报错org.apache.maven.plugin.war.WarMojo的解决办法
如题,maven项目eclipse提示pom.ml有错,提示信息就是org.apache.maven.plugin.war.WarMojo。
然后执行 maven install 出现如下错误提示
- [INFO] --- maven-war-plugin:2.2:war (default-war) @ ams-web ---
- [WARNING] Error injecting: org.apache.maven.plugin.war.WarMojo
- java.lang.TypeNotPresentException: Type org.apache.maven.plugin.war.WarMojo not present
- at org.eclipse.sisu.space.URLClassSpace.loadClass(URLClassSpace.java:111)
- at org.eclipse.sisu.space.NamedClass.load(NamedClass.java:46)
- at org.eclipse.sisu.space.AbstractDeferredClass.get(AbstractDeferredClass.java:48)
- at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:86)
- at com.google.inject.internal.InternalFactoryToInitializableAdapter.provision(InternalFactoryToInitializableAdapter.java:54)
- at com.google.inject.internal.ProviderInternalFactory$1.call(ProviderInternalFactory.java:70)
- at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:113)
- at org.eclipse.sisu.bean.BeanScheduler$Activator.onProvision(BeanScheduler.java:176)
- at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:122)
- at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:68)
- at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:68)
- at com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.java:46)
- at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1009)
- at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1059)
- at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1005)
- 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:263)
- at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:255)
- at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:464)
- at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:119)
- at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
- at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
- at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
- at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
- at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
- at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
- at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
- at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355)
- at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
- at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
- at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216)
- at org.apache.maven.cli.MavenCli.main(MavenCli.java:160)
- at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
- at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
- at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
- at java.lang.reflect.Method.invoke(Method.java:483)
- at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
- at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
- at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
- at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
- Caused by: java.lang.ClassNotFoundException: org.apache.maven.plugin.war.WarMojo
- at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
- at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
- at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
- at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
- at org.eclipse.sisu.space.URLClassSpace.loadClass(URLClassSpace.java:107)
- ... 41 more
解决办法:
pom.xml中增加插件
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-war-plugin</artifactId>
- <version>3.0.0</version>
- </plugin>
原本是没有设置这个插件,maven 应该自动使用了2.2版本的,换成3.0.0后,不在报这个错。为什么是3.0.0,我找了下我的本地仓库,有这个版本的,所以就没有尝试其他版本了。
猜测:这个项目以前是没有这个错误的,我更换本地的开发环境后,才出现的,以前是 JDK7 + myeclipse2014,后来我换成了JDK8 + eclipse 4.4了,IDE里面都是自己下载的同一个maven 3.2.5,所以我觉得应该是JDK版本和maven插件冲突了