5

I am trying to create web app using spring boot, maven and java 12. I started the project with spring-boot-starter-parent version 2.1.5.RELEASE, java 12 and maven-compiler-plugin version 3.8.1. I tried to run ./mvnw package but i got this error:

Fatal error compiling: invalid target release: 12

After that i wrote on the internet that maven compiler plugin uses old dependency for asm and i should specify new version of it. So i selected the latest version of asm which is 7.1 and i added configuration tag with properties release 12 and compilerArgs --enable-preview for java 12. The result was:

Fatal error compiling: invalid flag: --release

The next thing that i tried was to use spring boot starter parent version 2.2.0.M3 and to specify the repository to find milestone versions of spring from http://repo.spring.io/milestone. Unfortunately i got the same result. Any ideas?

3
  • invalid flag: --release indicates javac version below Java-9 in use. Commented Jun 7, 2019 at 10:23
  • 1
    @ThorbjørnRavnAndersen I doubt that, few links to prove that it supports Java-12 and might help people looking for a solution to a similar error - Compile a JDK12 preview feature with Maven and Error:java: error: invalid source release: 13 using JDK12 with IntelliJ. Commented Jun 7, 2019 at 10:48
  • @ThorbjørnRavnAndersen Why does maven-compiler-plugin not support JDK12 ? In which way? The Maven Team is running tests with JDK 12 and JDK13+EA ? Commented Jun 7, 2019 at 20:16

1 Answer 1

7

Trying with previous versions to spring boot 2.2.0.MX it also failed for me, but I have managed to make it work with 2.2.0.M6 including some plugins and tweaking them to adapt with the preview features like:

       <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <arguments>--enable-preview</arguments>
                    <jvmArguments>--enable-preview</jvmArguments>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.2</version>
                <configuration>
                    <argLine>--enable-preview</argLine>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <compilerArgs>--enable-preview</compilerArgs>
                </configuration>
            </plugin>
       </plugins>    

This is now working with Java 13.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.