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

前端 未结 23 2188
小蘑菇
小蘑菇 2020-11-29 15:55

I am using Maven 3.0.5 and Spring Tool Source 3.2 with Maven plugin installed. When I try to do \'Run As---> Maven install\', I am getting

相关标签:
23条回答
  • 2020-11-29 16:27

    I am adding more points to the solution by @Rushi Shah

    mvn clean install -X helps to identify the root cause.

    Some of the important phases of Maven build lifecycle are:

    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)

    The 1.6 under tag refers to JDK version. 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.

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

    0 讨论(0)
  • 2020-11-29 16:28

    check the property endorsed.dir tag in your pom.xml.
    I also had this problem and I fixed by modifying the property.

    Example:

    <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>  
    
    0 讨论(0)
  • 2020-11-29 16:29

    Java 9 incompatible

    I got this error when trying to calling mvn install on a project.

    I had installed Java 9 on macOS as well as Java 8 Update 144. My Maven project was apparently invoking Java 9 and failing. Removed Java 9 from my Mac, leaving just Java 8 in place. Maven is now happily building my project to successful completion.

    Using Apache Maven 3.5.0 on macOS Sierra.

    0 讨论(0)
  • 2020-11-29 16:30

    Deleting full .m2 local repository solved my problem, too.

    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** )
    
    0 讨论(0)
  • 2020-11-29 16:30

    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. i think the problem was absence of execution -> goal "endpoints_get_discovery_doc" in some cases like mine, so this worked for me.

    0 讨论(0)
  • 2020-11-29 16:33

    I think you have Two ways to solve this problem

    01. Set Properties

    • Set Java Build Path as 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

    • Specifi which kind of jdk version you installed

    Right click project ->Project Facets ->tick java and select java version->Apply ->Ok

    • Update project

    Right-click on "project"->Go to Maven->Update

    02.Delete .m2 file

    If you can't solve your problem using above two topic get this action Close your project. Delete your full .m2 folder

    How to fined .m2 file(windows)

    Go to Local Disk(C) ->Users ->Select your PC name ->.m2 file

    0 讨论(0)
提交回复
热议问题