1
1
お題は不問!Qiita Engineer Festa 2024で記事投稿!
Qiita Engineer Festa20242024年7月17日まで開催中!

[Mac] [Eclipse]「Spring スターター・プロジェクト」作成でエラー

Last updated at Posted at 2024-07-01

環境

  • MacBook Pro 2019 (Intel Mac)

  • macOS Monterey 12.6

  • Eclipse 2023-12 (4.30.0) Intel Mac 最終版

新規プロジェクト作成

scr 2024-07-01 15.41.11.png

新規に「Spring スターター・プロジェクト」を作成すると、しばらくして、エラーが発生した。

scr 2024-07-01 15.50.27.png

↑これを見ただけでは理由が分からない。

scr 2024-07-01 16.41.32.png

画面下部の「マーカー」タブを見ると、「Gradleエラー」だと分かる。
さらに詳細メッセージを見ると、以下の内容であった。

The supplied phased action failed with an exception.
Could not resolve all dependencies for configuration ':compileClasspath'.
Failed to calculate the value of task ':compileJava' property 'javaCompiler'.
Cannot find a Java installation on your machine matching this tasks requirements: {languageVersion=21, vendor=any, implementation=vendor-specific} for MAC_OS on x86_64.
No locally installed toolchains match and toolchain download repositories have not been configured.

Java関係のエラーらしい

以下のフォルダにある、EclipseにバンドルされているJavaを確認する。

$ ls /Applications/Eclipse_2023-12.app/Contents/java

11	17	21	8

Pleiades All in Oneサイトの案内のとおり、4バージョンがある。

scr 2024-07-01 16.03.41.png

今回は、先のエラーメッセージrequirements: languageVersion=21に従い、JDK21を使用することにする。パスは、以下とおり。

$ /Applications/Eclipse_2023-12.app/Contents/java/21/Home/bin/java --version

openjdk 21.0.2 2024-01-16 LTS
OpenJDK Runtime Environment Temurin-21.0.2+13 (build 21.0.2+13-LTS)
OpenJDK 64-Bit Server VM Temurin-21.0.2+13 (build 21.0.2+13-LTS, mixed mode)

Java VM の設定

↑上のパスを、Eclipse の Info.plist に追加する。

(テキストエディタならなんでもよく)Eclipse自身でも編集できるが、ここはVSCodeで編集した。

$ code /Applications/Eclipse_2023-12.app/Contents/Info.plist

scr 2024-07-01 15.48.49.png

66行目に次の一文を追加する。

<string>-vm</string><string>/Applications/Eclipse_2023-12.app/Contents/java/21/Home/bin/java</string>

scr 2024-07-01 15.49.00.png

忘れずに「保存」する。

Eclipse 再起動

Eclipseを一度終了し、再起動すると、自動的に復旧してくれるようで、
無事に「Spring スターター・プロジェクト」が作成されました。

scr 2024-07-01 16.24.57.png

おしまい

今回は Java VM を設定するという対策でしたが、
「Gradleエラー」でも他の要因のエラーもあると思われるので、この記事は、その中の一要因として まとめました。

1
1
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
1