简体   繁体   English

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

[英]Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile)

I am using Maven 3.0.5 and Spring Tool Source 3.2 with Maven plugin installed.我正在使用安装了 Maven 插件的Maven 3.0.5Spring Tool Source 3.2 When I try to do 'Run As---> Maven install', I am getting the following error:当我尝试执行“运行方式---> 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, i.e. 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

Please find below my pom.xml:请在我的 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>

During maven install my goal is war:war to make WAR of my application.在 maven 安装期间,我的目标是war:war来为我的应用程序制作 WAR。

Deleting full .m2/repository local repository solved my problem.删除完整的.m2/repository本地存储库解决了我的问题。

Or else you need to know what plugins are you using exactly with their dependencies as one of the plugin suffered a problem while downloading.否则,您需要知道您正在使用哪些插件及其依赖项,因为其中一个插件在下载时遇到了问题。

Deleting full .m2 local repository solved my problem, too.删除完整的 .m2 本地存储库也解决了我的问题。

If you don't know where it is, the locations are:如果你不知道它在哪里,位置是:

Unix/Mac OS X – ~/.m2/repository
Windows – C:\Documents and Settings\{your-username}\.m2\repository 
        ( %USERPROFILE%\.m2\repository too, as suggested by **MC Empero** )

I am adding more points to the solution by @Rushi Shah我正在为@Rushi Shah 的解决方案添加更多要点

mvn clean install -X helps to identify the root cause. mvn clean install -X有助于确定根本原因。

Some of the important phases of Maven build lifecycle are: Maven 构建生命周期的一些重要阶段是:

clean – the project is clean of all artifacts that came from previous compilations compile – the project is compiled into /target directory of project root install – packaged archive is copied into local maven repository (could in your user's home directory under /.m2) test – unit tests are run package – compiled sources are packaged into archive (JAR by default) clean – 项目清除了之前编译中的所有工件compile – 项目被编译到项目根目录的 /target 目录中install – 打包的存档被复制到本地 maven 存储库(可以在您用户的主目录中的 /.m2 下) test – 单元测试是运行package – 编译后的源代码被打包成存档(默认为 JAR)

The 1.6 under tag refers to JDK version.标签下的 1.6 指的是 JDK 版本。 We need to ensure that proper jdk version in our dev environment or change the value to 1.7 or 1.5 or whatever if the application can be supported in that JDK version.我们需要确保在我们的开发环境中使用正确的 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>

We can find the complete details on Maven build lifecycle in Maven site.我们可以在 Maven 站点中找到有关Maven 构建生命周期的完整详细信息。

I had the same problem, check the installed jre used by Maven in your Run Configuration...我遇到了同样的问题,请在您的运行配置中检查 Maven 使用的已安装 jre...

In your case, I think that the maven-compiler-plugin:jar:2.3.2 needs a jdk1.6在你的情况下,我认为 maven-compiler-plugin:jar:2.3.2 需要一个 jdk1.6

To do this : Run Configuration > YOUR_MAVEN_BUILD > JRE > Alternate JRE为此:运行配置 > YOUR_MAVEN_BUILD > JRE > 备用 JRE 在此处输入图片说明

Hope this helps.希望这可以帮助。

Sometimes it is caused due to the project points to JRE rather than JDK.So try this,有时是由于项目指向JRE而不是JDK引起的。所以试试这个,

1.Right Click on project -->Build Path --> Configure Build Path -->Add Library -->JRE System Library -->Environments--> Installed JREs-->Point to java folder in c: drive (Windows) and select JDK folder and ok. 1.右键项目-->构建路径-->配置构建路径-->添加库-->JRE系统库-->环境-->安装的JREs-->指向c:驱动器中的java文件夹(Windows ) 并选择 JDK 文件夹,然后确定。

2.Remove the already present JRE from build path. 2.从构建路径中删除已经存在的JRE。

Sometimes this issue comes because the java.version which you have mentioned in POM.xml is not the one installed in your machine.有时这个问题是因为你在 POM.xml 中提到的 java.version 不是你机器上安装的那个。

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

Ensure you exactly mention the same version in your pom.xml as the jdk and jre version present in your machine.确保在 pom.xml 中提到的版本与机器中存在的 jdk 和 jre 版本完全相同。

Usually, define maven-compiler-plugin is sufficient enough.通常,定义 maven-compiler-plugin 就足够了。 add the following to your compiler plugin definition.将以下内容添加到您的编译器插件定义中。

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

I had this problem once, and this is how i resolved it:我曾经遇到过这个问题,这就是我解决它的方法:

  • Step-1 Clean your步骤 1 清洁您的
    .m2/repository .m2/存储库

  • Step-2 execute the maven command(for example mvn clean verify ) from the terminal at the current project location(where your project's pom.xml file exist) instead of running maven from eclipse.步骤 2 从当前项目位置(项目的 pom.xml 文件所在的位置)的终端执行 maven 命令(例如mvn clean verify ),而不是从 eclipse 运行 maven。
  • Either remove the below code from the pom.xml or correct your java version to make it work.从 pom.xml 中删除以下代码或更正您的 java 版本以使其工作。

     <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.0</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin>

    Actually, if you do not want to delete your local .m2/repository/... and you are have a downloaded copy of Maven from Apache, you can have Eclipse /STS use that external Maven and you can edit the {maven}\\conf\\settings.xml to point your localRepository to a new empty location.实际上,如果您不想删除本地 .m2/repository/... 并且您有从 Apache 下载的 Maven 副本,您可以让 Eclipse /STS 使用该外部 Maven 并且您可以编辑 {maven}\\ conf\\settings.xml 将您的 localRepository 指向一个新的空位置。

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

    Of course, you will have a new repository with all of the maven source downloads in addition to your previous .m2 location.当然,除了之前的 .m2 位置之外,您还将拥有一个包含所有 maven 源下载的新存储库。

    在此处输入图片说明

    check the property endorsed.dir tag in your pom.xml .检查您的pom.xml的属性endorsed.dir标记。
    I also had this problem and I fixed by modifying the property.我也有这个问题,我通过修改属性来解决。

    Example:例子:

    <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>  
    

    Java 9 incompatible Java 9 不兼容

    I got this error when trying to calling mvn install on a project.尝试在项目上调用mvn install时出现此错误。

    I had installed Java 9 on macOS as well as Java 8 Update 144. My Maven project was apparently invoking Java 9 and failing.我已经在 macOS 上安装了 Java 9 以及 Java 8 Update 144。我的 Maven 项目显然是在调用 Java 9 并且失败了。 Removed Java 9 from my Mac, leaving just Java 8 in place.从我的 Mac 中删除了 Java 9,只留下 Java 8。 Maven is now happily building my project to successful completion. Maven 现在正在愉快地构建我的项目并成功完成。

    Using Apache Maven 3.5.0 on macOS Sierra.在 macOS Sierra 上使用 Apache Maven 3.5.0。

    None of the other answers suggests downloading just the missing plugin.其他答案都没有建议下载缺少的插件。

    Before you delete your whole .m2 repository and re-download all project dependencies and all plugins, you may want to try:在删除整个 .m2 存储库并重新下载所有项目依赖项和所有插件之前,您可能需要尝试:

    mvn dependency:resolve-plugins
    

    That will download just the missing plugins.这将只下载缺少的插件。

    • Download maven compiler plugin jar from your central repositoy n try从您的中央存储库下载 maven 编译器插件 jar 尝试
    • If it is still failing check your jdk version, it is because of your application is built on diff jdk version如果仍然失败,请检查您的 jdk 版本,这是因为您的应用程序是基于 diff jdk 版本构建的

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

    I think you have Two ways to solve this problem我认为你有两种方法可以解决这个问题

    01. Set Properties 01.设置属性

    • Set Java Build Path as jdk将 Java 构建路径设置为 jdk

    Right click project ->Java Build Path ->Select Libraries tab ->Select JRE System Library ->Click Edit button ->Click Installed JREs-> add tick to box ->click Edit ->Click Directory->Select jdk右键单击项目 ->Java 构建路径 -> 选择库选项卡 -> 选择 JRE 系统库 -> 单击编辑按钮 -> 单击已安装的 JRE -> 添加勾选框 -> 单击编辑 -> 单击目录 -> 选择 jdk

    • Specifi which kind of jdk version you installed指定你安装的是哪种jdk版本

    Right click project ->Project Facets ->tick java and select java version->Apply ->Ok右键单击项目 -> Project Facets -> 勾选 java 并选择 java version->Apply ->Ok

    • Update project更新项目

    Right-click on "project"->Go to Maven->Update右键单击“项目”-> 转到 Maven-> 更新

    02.Delete .m2 file 02.删除.m2文件

    If you can't solve your problem using above two topic get this action Close your project.如果使用上述两个主题无法解决问题,请执行此操作关闭您的项目。 Delete your full .m2 folder删除完整的 .m2 文件夹

    How to fined .m2 file(windows)如何罚款 .m2 文件(windows)

    Go to Local Disk(C) ->Users ->Select your PC name ->.m2 file转到本地磁盘(C)->用户->选择您的PC名称->.m2文件

    可能有文件被锁定在目标文件夹中

    Maybe you can add this dependency to your pom.xml.也许您可以将此依赖项添加到 pom.xml 中。 I use this method and solve the problem!我用这个方法解决了问题!

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

    for the new users on Mac os , find out .m2 folder and delete it, its on your /Users/.m2 directory.对于 Mac os 上的新用户,找出 .m2 文件夹并将其删除,它位于您的/Users/.m2目录中。

    you wont get to see .m2 folder in finder(File Explorer), for this user this command to Show Mac hidden files您不会在 finder(文件资源管理器)中看到.m2文件夹,对于此用户,此命令可显示 Mac 隐藏文件

    $ defaults write com.apple.finder AppleShowAllFiles TRUE $ 默认写入 com.apple.finder AppleShowAllFiles TRUE

    after this press alt and click on finder-> relaunch, you can see /Users/.m2按下alt并点击finder->重新启动后,你可以看到/Users/.m2

    to hide files again, simply use this $ defaults write com.apple.finder AppleShowAllFiles false要再次隐藏文件,只需使用$ defaults write com.apple.finder AppleShowAllFiles false

    I renamed the .m2 directory, this didn't help yet, so I installed the newest sdk/jdk and restarted eclipse.我重命名了 .m2 目录,这还没有帮助,所以我安装了最新的 sdk/jdk 并重新启动了 eclipse。 This worked.这奏效了。

    It seems an SDK was needed and I only had installed a JRE.似乎需要一个 SDK,而我只安装了一个 JRE。

    Which is weird, because eclipse worked on the same machine for a different older project.这很奇怪,因为 eclipse 在同一台机器上为不同的旧项目工作。

    I imported a second maven project, and Run/maven install did only complete after restarting eclipse.我导入了第二个 maven 项目,并且 Run/maven install 仅在重新启动 eclipse 后才完成。 So maybe just a restart of eclipse was necessary.所以也许只需要重新启动 eclipse。

    Importing yet another project, and had to do maven install twice before it worked even though I had restarted eclipse.导入另一个项目,即使我重新启动了 eclipse,也必须在它工作之前进行两次maven install

    It's really incredible to be oblige to erase whole .m2/repository content.不得不擦除整个 .m2/repository 内容真的令人难以置信。 I suggest to type this command (On Windows) :我建议输入这个命令(在 Windows 上):

    mvn clean清洁

    mvn -X package > my_log_file.log mvn -X 包 > my_log_file.log

    The last command enable Debug option et redirect output to a file.最后一个命令启用调试选项并将输出重定向到文件。 Open the file and search ERROR or WARNING key words.打开文件并搜索 ERROR 或 WARNING 关键字。 You can find this kind of expression :你可以找到这种表达方式:

    DEBUG] =======================================================================
    [WARNING] The POM for javax.servlet:javax.servlet-api:jar:4.0.0 is invalid, transitive dependencies (if any) will not be available: 1 problem was encountered while building the effective model for javax.servlet:javax.servlet-api:4.0.0
    [FATAL] Non-parseable POM C:\Users\vifie\.m2\repository\net\java\jvnet-parent\3\jvnet-parent-3.pom: processing instruction can not have PITarget with reserved xml name (position: END_TAG seen ...</profiles>\n\n</project>\n\n<?xml ... @160:7)  @ C:\Users\vifie\.m2\repository\net\java\jvnet-parent\3\jvnet-parent-3.pom, line 160, column 7
    
    [WARNING] The POM for org.glassfish:javax.json:jar:1.0.4 is invalid, transitive dependencies (if any) will not be available: 1 problem was encountered while building the effective model for org.glassfish:javax.json:[unknown-version]
    [FATAL] Non-parseable POM C:\Users\vifie\.m2\repository\net\java\jvnet-parent\3\jvnet-parent-3.pom: processing instruction can not have PITarget with reserved xml name (position: END_TAG seen ...</profiles>\n\n</project>\n\n<?xml ... @160:7)  @ C:\Users\vifie\.m2\repository\net\java\jvnet-parent\3\jvnet-parent-3.pom, line 160, column 7
    

    It's esay in this case to understand you have just to delete directory C:\\Users\\vifie.m2\\repository\\net\\java\\jvnet-parent\\3在这种情况下很容易理解你只需要删除目录 C:\\Users\\vifie.m2\\repository\\net\\java\\jvnet-parent\\3

    Relaunch compilation, packaging and so on :重新启动编译、打包等:

    mvn package mvn 包

    WARNING disappear just because you delete POM file corrupted at the good location and maven re download it.警告消失只是因为您删除了在好位置损坏的 POM 文件并 maven 重新下载它。 Normally the new POM file is better.通常新的 POM 文件更好。

    Often debug mode give you messages with more comprehensive details.调试模式通常会为您提供包含更全面详细信息的消息。

    Why I redirect log to a file : Simply because on Windows console don't have enough buffer to store all lines and often you cannot see all lines.为什么我将日志重定向到文件:仅仅是因为在 Windows 控制台上没有足够的缓冲区来存储所有行,而且通常您无法看到所有行。

    We tried everything listed so far and it still failed.我们尝试了到目前为止列出的所有内容,但仍然失败。 The error also mentioned错误还提到

    (default-war) on project utilsJava: Error assembling WAR: webxml attribute is required (default-war) 项目 utilsJava:组装 WAR 时出错:需要 webxml 属性

    The solution that finally fixed it was adding this to POM:最终修复它的解决方案是将其添加到 POM:

    <failOnMissingWebXml>false</failOnMissingWebXml>
    

    As mentioned here Error assembling WAR - webxml attribute is required正如这里提到的错误组装 WAR - webxml 属性是必需的

    Our POM now contains this:我们的 POM 现在包含以下内容:

    <plugin>
    <inherited>true</inherited>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>${maven-war-plugin.version}</version>
    <configuration>
    <failOnMissingWebXml>false</failOnMissingWebXml>
    <warName>${project.artifactId}</warName>
    <attachClasses>true</attachClasses>
    </configuration>
    </plugin>  
    

    It is because your Jenkins not able to find setting file.这是因为您的 Jenkins 无法找到设置文件。 If deleting .m2 not work, try below solution如果删除 .m2 不起作用,请尝试以下解决方案

    Go to your JOB configuration转到您的作业配置

    than to the Build section比构建部分

    Add build step :- Invoke top level maven target and fill Maven version and Goal添加构建步骤:- 调用顶级 maven 目标并填写 Maven 版本和目标

    than click on Advance button and mention settings file path as mention in image比单击高级按钮并提及设置文件路径,如图像中所述在此处输入图片说明

    It is because your Maven not able to find settings file.这是因为您的 Maven 无法找到设置文件。 If deleting .m2 not work, try below solution如果删除 .m2 不起作用,请尝试以下解决方案

    Go to your JOB configuration转到您的作业配置

    than to the Build section比构建部分

    Add build step :- Invoke top level maven target and fill Maven version and Goal添加构建步骤:- 调用顶级 maven 目标并填写 Maven 版本和目标

    than click on Advance button and mention settings file path as mention in image比单击高级按钮并提及设置文件路径,如图像中所述在此处输入图片说明

    In my case, a .properties file (Spring Boot's application.properties) contained an accentuated character at some point.就我而言,一个 .properties 文件(Spring Boot 的 application.properties)在某些时候包含一个重音字符。 As you can see, it was treated as critical error, due to this IOUtil.copy using a Reader as a source, so it decodes the byte stream while copying, which is always a good source of hard to guess exceptions.如您所见,它被视为严重错误,因为此 IOUtil.copy 使用 Reader 作为源,因此它在复制时解码字节流,这始终是难以猜测异常的好来源。

    Caused by: java.nio.charset.MalformedInputException: Input length = 1
        at java.nio.charset.CoderResult.throwException (CoderResult.java:274)
        at sun.nio.cs.StreamDecoder.implRead (StreamDecoder.java:339)
        at sun.nio.cs.StreamDecoder.read (StreamDecoder.java:178)
        at java.io.InputStreamReader.read (InputStreamReader.java:185)
        at java.io.BufferedReader.read1 (BufferedReader.java:210)
        at java.io.BufferedReader.read (BufferedReader.java:287)
        at java.io.BufferedReader.fill (BufferedReader.java:161)
        at java.io.BufferedReader.read (BufferedReader.java:182)
        at org.apache.maven.shared.filtering.BoundedReader.read (BoundedReader.java:85)
        at org.apache.maven.shared.filtering.MultiDelimiterInterpolatorFilterReaderLineEnding.read (MultiDelimiterInterpolatorFilterReaderLineEnding.java:235)
        at org.apache.maven.shared.filtering.MultiDelimiterInterpolatorFilterReaderLineEnding.read (MultiDelimiterInterpolatorFilterReaderLineEnding.java:197)
        at java.io.Reader.read (Reader.java:229)
        at org.apache.maven.shared.utils.io.IOUtil.copy (IOUtil.java:199)
        at org.apache.maven.shared.utils.io.IOUtil.copy (IOUtil.java:181)
        at org.apache.maven.shared.utils.io.FileUtils.copyFile (FileUtils.java:1908)
    

    Check the JDK version in pom.xml在 pom.xml 中检查 JDK 版本

    <properties>
        <java.version>11</java.version>     
    </properties>
    

    这是变量名中的一个错字,导致我遇到了这个问题,

    <finalName>${project.artifactId}</finalName>
    

    Sometimes it may be due to the use of wrong java version.有时可能是由于使用了错误的java版本。 Check the java version supported for the tool you are going to use.检查您要使用的工具支持的 Java 版本。 In my case, it was due to java 8 be used on maven build and it supposed to be JAVA 11.就我而言,这是由于在 maven 构建中使用了 java 8,它应该是 JAVA 11。

    Change the version before do mvn clean install在执行mvn clean install之前更改版本

    by command for Linux export JAVA_HOME=<path>通过 Linux export JAVA_HOME=<path>

    Had the same issue while converting my project to JDK 11 The suggested removing the .m2/repository did not work Gone through almost all the suggestions mentioned on the internet but no luck在将我的项目转换为 JDK 11 时遇到了同样的问题建议删除 .m2/repository 没有工作通过互联网上提到的几乎所有建议,但没有运气

    What I did was remove all the dependencies from the child module pom.xml and add them one by one again.我所做的是从子模块 pom.xml 中删除所有依赖项并再次添加它们。 This method was a success and worked like a charm这种方法很成功,而且效果很好

    The problem I had was some of the dependency was changed in the new JDK 11 and need to separately add to the pom.xml.我遇到的问题是一些依赖项在新的 JDK 11 中发生了变化,需要单独添加到 pom.xml。 The codebase did not show any error even cleaning the .m2/repository did not.代码库没有显示任何错误,即使清理 .m2/repository 也没有。 So had to follow use this solution所以不得不遵循使用这个解决方案

    I got this when I unwittingly had two references to maven-war-plugin in my pom, one in and one in the executions section to get around the Eclipse Lifecycle issue.当我无意中在我的 pom 中有两个对 maven-war-plugin 的引用时,我得到了这个,一个在执行部分,一个在执行部分,以解决 Eclipse 生命周期问题。 I fixed both to 3.3.2 and it worked just fine我将两者都固定为 3.3.2 并且效果很好

    I am using Intellij IDE and If you are getting this error don't use terminal.我正在使用 Intellij IDE,如果遇到此错误,请不要使用终端。 Use Maven tab on IDE and在 IDE 上使用 Maven 选项卡和

    Select your project and do these steps;选择您的项目并执行以下步骤;

    1. Click clean点击清理
    2. Click install点击安装

    It works for me这个对我有用

    在此处输入图片说明

    i had the same problem and besides the above posts' configurations putting我有同样的问题,除了上述帖子的配置

                <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>
    

    in the plugins element in pom.xml.在 pom.xml 的 plugins 元素中。 i think the problem was absence of execution -> goal "endpoints_get_discovery_doc" in some cases like mine, so this worked for me.我认为问题在于没有执行 ->在像我这样的某些情况下,目标“endpoints_get_discovery_doc” ,所以这对我有用。

    暂无
    暂无

    声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

    相关问题 未能执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) - Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) 无法在项目acme模块上执行目标org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile(default-compile):编译失败: - Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project acme-module: Compilation failure: 无法在项目 dbproxy 上执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.0:compile (default-compile): - Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.0:compile (default-compile) on project dbproxy: 无法执行目标 org.apache.maven.plugins:maven-compiler-plugin:2。 3.2:在项目aopencommon上编译(默认编译) - Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2. 3.2:compile (default-compile) on project aopencommon 无法在项目上执行目标org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile(default-compile) - Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project 无法执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) - Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) 未能执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) - Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) 无法执行目标org.apache.maven.plugins:maven-compiler-plugin:3.5.1:在项目上编译(default-compile) - Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (default-compile) on project “无法执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile)” - "Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile)" 无法在项目上执行目标org.apache.maven.plugins:maven-compiler-plugin:3.3:compile(default-compile) - Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:compile (default-compile) on project
     
    粤ICP备18138465号  © 2020-2024 STACKOOM.COM