LoginSignup
1
0

More than 1 year has passed since last update.

【Maven】Fatal error compiling: エラー: リリース・バージョン17はサポートされていません

Posted at

はじめに

Mavenで「mvn spring:run」をしたらタイトルのエラーが出たので解決方法をメモしておく。

状況

Mavenで指定しているバージョンは17。

pom.xml
	<properties>
		<java.version>17</java.version>
	</properties>

端末のJavaのバージョンは17。

> java -version
java version "17.0.2" 2022-01-18 LTS
Java(TM) SE Runtime Environment (build 17.0.2+8-LTS-86)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.2+8-LTS-86, mixed mode, sharing)

あれれ

解決方法1

mvn -versionをすると分かるように、Mavenでは環境変数のJAVA_HOMEを使う。

> mvn -version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: C:\maven\bin\..
Java version: 12.0.1, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk-12.0.1
Default locale: ja_JP, platform encoding: MS932
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

> set JAVA_HOME
JAVA_HOME=C:\Program Files\Java\jdk-12.0.1

今回は、バージョン12が指定されていました。
なので、JAVA_HOMEで指定するJavaのバージョンを17に変更すると解消しました。
めでたしめでたし。

参考

補足

ちなみにエラーログ抜粋。

> mvn spring-boot:run
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------< com.kyosoba:detail-api >-----------------------
[INFO] Building detail-api 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] >>> spring-boot-maven-plugin:3.1.0:run (default-cli) > test-compile @ detail-api >>>
[INFO]
[INFO] --- maven-resources-plugin:3.3.1:resources (default-resources) @ detail-api ---
[INFO] Copying 1 resource from src\main\resources to target\classes
[INFO] Copying 0 resource from src\main\resources to target\classes
[INFO]
[INFO] --- maven-compiler-plugin:3.11.0:compile (default-compile) @ detail-api ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.3.1:testResources (default-testResources) @ detail-api ---
[INFO] skip non existing resourceDirectory 
[INFO]
[INFO] --- maven-compiler-plugin:3.11.0:testCompile (default-testCompile) @ detail-api ---
[INFO] Changes detected - recompiling the module! :input tree
[INFO] Compiling 1 source file with javac [debug release 17] to target\test-classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  6.164 s
[INFO] Finished at: 2023-05-21T07:43:24+09:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:testCompile (default-testCompile) on project detail-api: Fatal error compiling: エラー: リリース・バージョン17はサポートされていません -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:testCompile (default-testCompile) on project detail-api: Fatal error compiling
----以下省略-----
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0