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

前端 未结 10 619
长情又很酷
长情又很酷 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:49

    For the new Apache net Bean its a little bit different from the suggestion by SUPARNA SOMAN

    • Right Click on your Project -Hover on "set configuration" and click customize configuration -.A new dialogue box opens....
    • At the left corner where the categories are, Click on "Source"
    • At the select form on the page below, select your required version of JDK ----see image for this last step.the last step required to change jdk version
    0 讨论(0)
  • 2021-02-01 01:49

    Also in one of my projects, in addition to all of answers above, another try works: Just change Language level in Modules section of Project Structure [image below] [Language Level]1

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

    I had same issue, the problem is with properties. Check your JavaSE version in your project, it will be displayed beside JRE System Library folder in your project. If it is 1.5, then it will throw an error. Most probably you will have a updated version, so check the version and update it. I have updated it below based on your code.

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

    I think you have wrong your pom.xml:

    <properties>
       <maven.compiler.source>6</maven.compiler.source>
       <maven.compiler.target>1.6</maven.compiler.target>
     </properties>
    

    change to:

    <properties>
       <maven.compiler.source>1.6</maven.compiler.source>
       <maven.compiler.target>1.6</maven.compiler.target>
     </properties>
    

    Now depending if you are using the command line use:

    mvn clean compile

    or either way(eclipse ide)

    Right click on project Run with maven>build>Goal (compile)

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