Maven is not using Java 11 - Fatal error compiling: invalid target release: 11

前端 未结 3 592
萌比男神i
萌比男神i 2021-01-12 11:17

I am trying to compile my project with Java 11.

When I try to run the application with Java 8 as the Java version in pom.xml, it works fine. But when I try to run it

相关标签:
3条回答
  • 2021-01-12 11:43

    Experiencing this issue while trying to deploy Spring Boot application to Heroku.

    My JAVA_HOME was set correctly but was still receiving same error.

    But then this worked for me:

    In your pom.xml add or adapt to your own context:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
            <source>1.8</source>
            <target>1.8</target>
        </configuration>
    </plugin>
    
    0 讨论(0)
  • 2021-01-12 11:53

    just change this

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

    to

    <properties>
        <java.version>1.8</java.version>
    </properties>
    
    0 讨论(0)
  • 2021-01-12 12:03

    Seems like you're having the JAVA_HOME set in your mvn.bat. It could be pointing to the older version of Java (i.e. 11 in your case).

    set JAVA_HOME=C:\path\to\jdk11 try using it on the first line, before calling maven.

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