新規SpringBootファイルビルドプロセス失敗のエラー
spring initializrのサイトで生成した新規SpringBootファイルをIntelliJ IDEAで開き、実行したところ、下記のエラーとなった。
Execution failed for task ':processResources'.
> Cannot convert URL 'application.properties:Zone.Identifier' to a file.
*Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.5/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD FAILED in 1s
2 actionable tasks: 1 executed, 1 up-to-date
エラー内容
最初の2行がエラー内容。
application.propertiesのタスクに失敗。application.properties:Zone.Identifierがファイル変換できない。
エラー原因
チャットGPT先生によると
Zone.Identifier はWindowsがファイルに付与するメタデータ(別名「代替データストリーム」)で、インターネットからダウンロードされたファイルのゾーン情報を格納します。このメタデータは、Unix系のシステムやJavaのFile APIでは直接サポートされていません。
とのことであった。
私はintelliJをWindows環境ではなく仮想Linux環境で使用している。
spring initializrのサイトで生成した新規SpringBootファイルは、WindowsのDownloadフォルダに入ってしまう(デフォルト設定)。それをLinux環境に持ち込んだ際に生成されてしまうようだ。
対応
これだけが原因なのかわからなかったが、プログラムに不必要なファイルではあるので、削除してみることにした。ただ、*:Zone.Identifierのファイルは全てのファイルに対して生成されるので、手作業で全てを消すのはひどい手間になりそうであった。
ググると下記のリンクがヒットした。
こちらで紹介されていた一括削除コマンドで削除できた。
$ find ./ -type f -name '*:Zone.Identifier' -exec rm {} \;
一発K.O.であった。激しく感謝です。
結果
*:Zone.Identifierを全て削除した結果、エラーにならずにビルドすることができた。
*:Zone.Identifier生成自体をさせないようにすることも、もしかしたらできるのかもしれないが、何かしら必要で生成されているはず(そこまでは調べなかった)。
もうワンパン解決なので怖くない。