事象
- mvn compile で "Source option 5 is no longer supported. Use 6 or later." と怒られる
$ mvn compile
[INFO] Compiling 1 source file to /home/ec2-user/myapp/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] Source option 5 is no longer supported. Use 6 or later.
[ERROR] Target option 1.5 is no longer supported. Use 1.6 or later.
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
解決策
- プロジェクトフォルダ直下の pom.xml に以下を追記する
<properties>
<mavencompilersource>11</mavencompilersource>
<mavencompilertarget>11</mavencompilertarget>
<projectbuildsourceEncoding>UTF-8< /project.build.sourceEncoding>
</properties>
$ mvn compile
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building myapp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ myapp ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/ec2-user/myapp/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ myapp ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/ec2-user/myapp/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.625 s
[INFO] Finished at: 2023-07-11T05:33:48+00:00
[INFO] Final Memory: 12M/30M
[INFO] ------------------------------------------------------------------------