Error “Source option 5 is no longer supported. Use 6 or later” on Maven compile

前端 未结 10 616
长情又很酷
长情又很酷 2021-02-01 01:27

I am getting the following error or $ mvn compile:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on         


        
相关标签:
10条回答
  • 2021-02-01 01:34

    This helped me:

    1. Right Click on Project.
    2. Click on Build path.
    3. Click on Configure Build path.
    4. It opens a Java Build path window.
    5. Click on Java Compiler in the Left side.
    6. It navigates to Java Compiler window in that to set the Compiler compliance level is set as according to your jre version(ex if java version is 1.8 then choose 1.8) as select.
    7. Click on [Apply] button.
    8. Click on [OK] button.
    9. Right click on Project > Maven > Update the project.
    10. Right click on Project > Run As > Maven install -- The pom.xml file is running and java jars are download and installed to project.
    11. Right click on Project > Run As > Maven Test -- The pom.xml file is running and java jars are download and installed to project.

    Then you got the Build Success message and your maven project is created successfully.

    0 讨论(0)
  • 2021-02-01 01:36

    What helped me was these lines in pom.xml file

    <properties>
         <maven.compiler.source>1.8</maven.compiler.source>
         <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
    
    0 讨论(0)
  • 2021-02-01 01:38

    I was facing the same issue and resolved it with the lines of code below:

    <properties>
       <maven.compiler.source>1.6</maven.compiler.source>
       <maven.compiler.target>1.6</maven.compiler.target>
     </properties>
    
    0 讨论(0)
  • 2021-02-01 01:41

    On MacOS I have multiple versions

    user> ls /Library/Java/JavaVirtualMachines/
    jdk-11.0.4.jdk      jdk-12.0.2.jdk      jdk1.8.0_221.jdk
    

    and JAVA_HOME was not defined properly so Maven used jdk-12. I have jdk-11,jdk-8, and jdk-12.

    user> mvn -version
    Apache Maven 3.6.1 
    Maven home: /usr/local/Cellar/maven/3.6.1/libexec
    Java version: 12.0.2, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home
    Default locale: XXX, platform encoding: UTF-8
    OS name: "mac os x", version: "10.14.6", arch: "x86_64", family: "mac"
    

    So:

    Define JAVA_HOME to use jdk-8.

    export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_221.jdk/Contents/Home
    

    Try again, now maven is:

    user> mvn -version
        Maven home: /usr/local/Cellar/maven/3.6.1/libexec
        Java version: 1.8.0_221, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_221.jdk/Contents/Home/jre
    

    and the build is:

    [INFO] BUILD SUCCESS
    
    0 讨论(0)
  • 2021-02-01 01:44

    Here is the solution which helped me:

    I had the same issue on error source option 5 is no longer supported, Use 6 or later

    So i followed these instructions and problem SOLVED

    1. Open Project Properties (File Menu)
    2. Change the Source / Binary Format to the latest version (JDK 7 in my case)

    Project Properties

    Source / Binary Format

    Clean and Build, Then Run the project

    0 讨论(0)
  • 2021-02-01 01:45

    I had same issue and i have added below configuration in pom.xml and it works.

    <build>
       <plugins>
       <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.5.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
       </plugins>
       </build>
    
    0 讨论(0)
提交回复
热议问题