无法执行目标org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile(default-compile)

我使用安装了Maven插件的Maven 3.0.5和Spring Tool Source 3.2。 当我尝试做“运行—> Maven安装”,我得到以下错误:

[INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building Spring Social Twitter4J Sample 1.0.0 [INFO] ------------------------------------------------------------------------ [WARNING] The POM for org.apache.maven.plugins:maven-compiler-plugin:jar:2.3.2 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details [WARNING] The POM for org.apache.maven.plugins:maven-war-plugin:jar:2.1.1 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details [WARNING] The POM for org.apache.maven.plugins:maven-install-plugin:jar:2.3.1 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details [INFO] [INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ spring-social-twitter4j --- [debug] execute contextualize [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, ie build is platform dependent! [INFO] Copying 15 resources [INFO] [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ spring-social-twitter4j --- [WARNING] The POM for org.apache.maven.plugins:maven-compiler-plugin:jar:2.3.2 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details Jun 21, 2013 2:14:32 AM org.sonatype.guice.bean.reflect.Logs$JULSink warn WARNING: Error injecting: org.apache.maven.plugin.CompilerMojo **java.lang.NoClassDefFoundError: org/codehaus/plexus/compiler/CompilerException** at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Unknown Source) at java.lang.Class.getDeclaredConstructors(Unknown Source) at com.google.inject.spi.InjectionPoint.forConstructorOf(InjectionPoint.java:245) at com.google.inject.internal.ConstructorBindingImpl.create(ConstructorBindingImpl.java:98) at com.google.inject.internal.InjectorImpl.createUninitializedBinding(InjectorImpl.java:629) at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:831) at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:758) at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:255) at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:204) at com.google.inject.internal.InjectorImpl.getProviderOrThrow(InjectorImpl.java:954) at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:987) at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:950) at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1000) at org.sonatype.guice.bean.reflect.AbstractDeferredClass.get(AbstractDeferredClass.java:45) at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:84) at com.google.inject.internal.InternalFactoryToInitializableAdapter.provision(InternalFactoryToInitializableAdapter.java:52) at com.google.inject.internal.ProviderInternalFactory$1.call(ProviderInternalFactory.java:70) at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:100) at org.sonatype.guice.plexus.lifecycles.PlexusLifecycleManager.onProvision(PlexusLifecycleManager.java:138) at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:108) at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:55) at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:68) at com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.java:45) at com.google.inject.internal.InjectorImpl$3$1.call(InjectorImpl.java:965) at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1011) at com.google.inject.internal.InjectorImpl$3.get(InjectorImpl.java:961) at com.google.inject.Scopes$1$1.get(Scopes.java:59) at org.sonatype.guice.bean.locators.LazyBeanEntry.getValue(LazyBeanEntry.java:83) at org.sonatype.guice.plexus.locators.LazyPlexusBean.getValue(LazyPlexusBean.java:49) at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:253) at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:245) at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:455) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:92) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) 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:84) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) at org.apache.maven.cli.MavenCli.main(MavenCli.java:141) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) Caused by: java.lang.ClassNotFoundException: org.codehaus.plexus.compiler.CompilerException at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50) at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244) at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230) ... 54 more [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2.749s [INFO] Finished at: Fri Jun 21 02:14:32 IST 2013 [INFO] Final Memory: 4M/15M [INFO] ------------------------------------------------------------------------ **[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project spring-social-twitter4j: Execution default-compile of goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile failed: A required class was missing while executing org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile: org/codehaus/plexus/compiler/CompilerException** [ERROR] ----------------------------------------------------- [ERROR] realm = plugin>org.apache.maven.plugins:maven-compiler-plugin:2.3.2 [ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy [ERROR] urls[0] = file:/C:/Users/SS%20Computer/.m2/repository/org/apache/maven/plugins/maven-compiler-plugin/2.3.2/maven-compiler-plugin-2.3.2.jar [ERROR] urls[1] = file:/C:/Users/SS%20Computer/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar [ERROR] Number of foreign imports: 1 [ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]] [ERROR] [ERROR] -----------------------------------------------------: org.codehaus.plexus.compiler.CompilerException [ERROR] -> [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/PluginContainerException 

请在下面find我的pom.xml文件:

 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.springframework.social.samples</groupId> <artifactId>spring-social-twitter4j</artifactId> <name>Spring Social Twitter4J Sample</name> <packaging>war</packaging> <version>1.0.0</version> <properties> <java-version>1.6</java-version> <org.springframework.social-version>1.1.0.BUILD-SNAPSHOT</org.springframework.social-version> <org.springframework-version>3.2.1.RELEASE</org.springframework-version> <org.springframework.security-version>3.1.3.RELEASE</org.springframework.security-version> <org.slf4j-version>1.7.2</org.slf4j-version> </properties> <dependencies> <!-- Spring --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${org.springframework-version}</version> <exclusions> <!-- Exclude Commons Logging in favor of SLF4j --> <exclusion> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${org.springframework-version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>${org.springframework-version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> <version>${org.springframework-version}</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-web</artifactId> <version>${org.springframework.security-version}</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-taglibs</artifactId> <version>${org.springframework.security-version}</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-config</artifactId> <version>${org.springframework.security-version}</version> </dependency> <dependency> <groupId>org.springframework.social</groupId> <artifactId>spring-social-core</artifactId> <version>${org.springframework.social-version}</version> </dependency> <dependency> <groupId>org.springframework.social</groupId> <artifactId>spring-social-web</artifactId> <version>${org.springframework.social-version}</version> </dependency> <!-- Twitter4J --> <dependency> <groupId>org.twitter4j</groupId> <artifactId>twitter4j-core</artifactId> <version>2.2.3</version> </dependency> <!-- JSR 303 with Hibernate Validator --> <dependency> <groupId>javax.validation</groupId> <artifactId>validation-api</artifactId> <version>1.0.0.GA</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> <version>4.1.0.Final</version> </dependency> <!-- Logging --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>${org.slf4j-version}</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>jcl-over-slf4j</artifactId> <version>${org.slf4j-version}</version> <scope>runtime</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>${org.slf4j-version}</version> <scope>runtime</scope> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.16</version> <scope>runtime</scope> </dependency> <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <version>1.3.159</version> </dependency> <!-- @Inject --> <dependency> <groupId>javax.inject</groupId> <artifactId>javax.inject</artifactId> <version>1</version> </dependency> <!-- CGLIB, only required and used for @Configuration usage --> <dependency> <groupId>cglib</groupId> <artifactId>cglib-nodep</artifactId> <version>2.2</version> </dependency> <!-- Servlet --> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <version>2.1</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet.jsp.jstl</groupId> <artifactId>jstl-api</artifactId> <version>1.2</version> </dependency> <dependency> <groupId>org.glassfish.web</groupId> <artifactId>jstl-impl</artifactId> <version>1.2</version> </dependency> </dependencies> <repositories> <repository> <id>org.springframework.maven.release</id> <name>Spring Maven Release Repository</name> <url>http://maven.springframework.org/release</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>false</enabled></snapshots> </repository> <!-- For testing against latest Spring snapshots --> <repository> <id>org.springframework.maven.snapshot</id> <name>Spring Maven Snapshot Repository</name> <url>http://maven.springframework.org/snapshot</url> <releases><enabled>false</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </repository> <!-- For developing against latest Spring milestones --> <repository> <id>org.springframework.maven.milestone</id> <name>Spring Maven Milestone Repository</name> <url>http://maven.springframework.org/milestone</url> <snapshots><enabled>false</enabled></snapshots> </repository> </repositories> <build> <resources> <resource> <directory>src/main/java</directory> </resource> </resources> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>${java-version}</source> <target>${java-version}</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.1.1</version> <configuration> <warName>spring-social-twitter4j</warName> </configuration> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>tomcat-maven-plugin</artifactId> <version>1.1</version> </plugin> </plugins> </build> </project> 

在maven安装期间,我的目标是战争:战争,使我的应用程序的战争。 任何及时的帮助,将不胜感激。

删除完整的.m2/repository本地存储库解决了我的问题。

否则,你需要知道什么插件使用完全与他们的依赖关系,因为其中一个插件在下载时遇到了问题。

删除完整的.m2本地存储库也解决了我的问题。

如果你不知道它在哪里,位置是:

 Unix/Mac OS X – ~/.m2/repository Windows – C:\Documents and Settings\{your-username}\.m2\repository 

我正在给@Rushi Shah添加更多的解决scheme

mvn clean install -X有助于确定根本原因。

Maven构build生命周期的一些重要阶段是:

clean – 项目清理所有来自先前编译的工件compile – 将项目编译到项目root install / target目录 – 打包的压缩文件被复制到本地的maven仓库(可以在你的用户的主目录下的/.m2)test – unit testing运行package – 编译的源代码打包到压缩文件中(默认为JAR)

1.6下标签是指JDK版本。 我们需要确保在我们的开发环境中使用正确的jdk版本,或者将值更改为1.7或1.5,或者在该JDK版本中支持应用程序。

 <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.0</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> </plugins> </build> 

我们可以在Maven站点上find关于Maven构build生命周期的完整细节。

我有同样的问题,检查您的运行configuration中使用的Maven安装的JRE …

在你的情况下,我认为maven-compiler-plugin:jar:2.3.2需要一个jdk1.6

要这样做:运行configuration> YOUR_MAVEN_BUILD> JRE>替代JRE 在这里输入图像说明

希望这可以帮助。

有时候是因为项目指向JRE而不是JDK导致的。所以试试这个,

1.右键单击项目 – >构buildpath – >configuration构buildpath – >添加库 – > JRE系统库 – >环境 – >已安装的JRE – >指向C:驱动器(Windows )并selectJDK文件夹并确定。

2.从构buildpath中删除已经存在的JRE。

通常,定义maven-compiler-plugin就足够了。 将以下内容添加到您的编译器插件定义中。

 <plugin> <inherited>true</inherited> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> </plugin> 

实际上,如果你不想删除你的本地.m2 / repository / …,并且你有一个Apache的Maven的下载副本,你可以让Eclipse / STS使用这个外部的Maven,你可以编辑{maven} conf \ settings.xml将你的localRepository指向一个新的空白位置。

 <localRepository>C:\java\repository</localRepository> 

当然,除了之前的.m2位置之外,您还将拥有一个包含所有Maven源代码下载的新存储库。

在这里输入图像说明

检查您的pom.xml的属性endorsed.dir标签。
我也有这个问题,我通过修改属性来修复。

例:

 <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir> 
  • 从你的中央repositoy下载Maven编译器插件jar试试
  • 如果还没有检查你的jdk版本,那是因为你的应用程序是build立在diff jdk版本上的

有时候会出现这个问题,因为你在POM.xml中提到的java.version不是安装在你的机器上的。

 <properties> <java.version>1.7</java.version> </properties> 

确保你在你的pom.xml中提供与你的机器中存在的jdk和jre版本相同的版本。

我想你有两种方法来解决这个问题

01.设置属性

  • 将Java Build Path设置为jdk

右键单击项目 – > Java Build Path – >select库选项卡 – >selectJRE系统库 – >点击编辑button – >点击已安装的JREs->添加勾选框 – >点击编辑 – >点击目录 – >selectjdk

  • Specifi你安装的那种jdk版本

右键点击project – > Project Facets – >勾选java,selectjava version-> Apply – > Ok

  • 更新项目

右键单击“项目” – >转到Maven->更新

02.删除.m2文件

如果使用上述两个主题无法解决您的问题,请执行此操作closures您的项目。 删除完整的.m2文件夹

如何罚款.m2文件(Windows)

转到本地磁盘(C) – >用户 – >select您的电脑名称 – >。m2文件

也许你可以添加这个依赖到你的pom.xml。 我用这个方法解决问题!

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

对我来说,重新启动Eclipse摆脱了这个错误!

对于Mac OS上的新用户,找出.m2文件夹并将其删除,将其放在/Users/.m2目录中。

你将无法在Finder(文件资源pipe理器)中看到.m2文件夹,为此用户此命令显示Mac隐藏文件

$ defaults写入com.apple.finder AppleShowAllFiles TRUE

按此之后,点击finder->重新启动,你可以看到/Users/.m2

再次隐藏文件,只需使用这个$ defaults写入com.apple.finder AppleShowAllFiles为false

Java 9不兼容

尝试在项目上调用mvn install时出现此错误。

我已经在macOS上安装了Java 9以及Java 8 Update 144.我的Maven项目显然是调用Java 9并失败。 从我的Mac删除了Java 9,只留下了Java 8。 Maven现在正在愉快地构build我的项目,以便顺利完成。

在macOS Sierra上使用Apache Maven 3.5.0。

我有同样的问题,除了上述职位的configuration

  <plugin> <groupId>com.google.appengine</groupId> <artifactId>appengine-maven-plugin</artifactId> <version>1.9.32</version> <configuration> <enableJarClasses>false</enableJarClasses> </configuration> <executions> <execution> <goals> <goal>endpoints_get_discovery_doc</goal> </goals> </execution> </executions> </plugin> 

在pom.xml的插件元素中。 我认为问题是没有执行 – >目标“endpoints_get_discovery_doc”在一些像我的情况下,所以这对我工作。