Maven build Compilation error : Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Maven

前端 未结 19 1533
说谎
说谎 2020-12-01 01:17

I have a maven project forked and cloned from a git repo onto my eclipse. It is build on Java 8. The first thing i do is perform a

mvn clean install


        
相关标签:
19条回答
  • 2020-12-01 01:37

    Doing this in pom.xml file and after updating the project, the problem is gone.

    <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
    </configuration>
    </plugin>
    
    1. Update the pom.xml under <plugin></plugin>.

    2. Update your project.

    3. Then clean maven and install maven.

    0 讨论(0)
  • 2020-12-01 01:38

    In my case, it was caused from an incompatibility with OpenJDK 9 (which I haven't investigated).

    If you don't need JDK 9, a temporary work-around would be to purge it from your machine:

    sudo apt-get remove --purge openjdk-9-jdk openjdk-9-jre 
    sudo apt-get remove --purge openjdk-9-jdk-headless openjdk-9-jre-headless
    
    0 讨论(0)
  • 2020-12-01 01:40

    Buddy,
    If every this is up-to-date, even then you are having this problem, then
    try running this command from the terminal directly instead of running from eclipse.
    $ mvn clean install

    and make sure these things:

    • maven is in system path
    • all maven dependencies are avaialble at `.m2/repository`
    • java is in system path


    0 讨论(0)
  • 2020-12-01 01:40

    for it was comming because of java version mismatch ,so I have corrected it and i am able to build the war file.hope it will help someone

        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>
    
    0 讨论(0)
  • 2020-12-01 01:40

    The below pom.xml configuration is making the build successful and make sure project buildpath JRE System library should point to Java8.

    org.apache.maven.pluginsmaven-compiler-plugin3.7.0 1.81.8

    0 讨论(0)
  • 2020-12-01 01:41

    Worked by adding this in pom.xml:

    <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <maven.compiler.source>1.8</maven.compiler.source>
            <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
    

    Even you have SDK 13 or 14.

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