I use the Spring Dashboard in Eclipse to create the project. I've also tried creating it using Spring Initializr and tried both version 8 and 9 of java, but I still get this. Also tried to change the maven target. Run configuration, maven build is using the JavaSE1.8, jre 1.8.0.
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RC2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>9</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Command:
javac version: 9.0.4
Apache Maven 3.5.2
Maven home: C:\Users\arito\Desktop\apache-maven-3.5.2\bin\..
Java version: 1.8.0_152, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_152\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
I solve this issue using the following configuration:
<build>
<plugins>
<!-- target Java 9 -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<!-- fork compilation and use the
specified executable -->
<fork>true</fork>
<executable>javac9</executable>
</configuration>
</plugin>
</plugins>
</build>
There are another alternatives like Maven Toolchains or the mavenrc file.
I had to use to java 9 not 8.
I switched java environments in MacOS:
List java versions installed: /usr/libexec/java_home -V
Switch to java 9: export JAVA_HOME=`/usr/libexec/java_home -v 9.0.4`
(I had java 9 installed from before)
Source: How to set JAVA_HOME environment variable on Mac OS X 10.9?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With