Building Maven Projects in Eclipse - MojoExecutionException
eclipseのmavenビルドエラーを解決した
~~~~
単純なmavenプロジェクトを作った
内容:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>guru.springframework</groupId>
<artifactId>hello-world</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>12</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.8.1</version>
</dependency>
</dependencies>
</project>
→ clrでは、mvn clean package が成功する
生成されるmanifestのでは、 「Build-Jdk: 12.0.2」
→ Pathに指定しているjdkは12だから
しかし、eclipseで同じプロジェクトを clean package をしようとすると
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project hello-world: Fatal error compiling: 12は無効なターゲット・リリースです -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project hello-world: Fatal error compiling
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:215)
。。。
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
調べたところ、以下の人気ある回答で一応ビルドできた
https://stackoverflow.com/questions/42525139/maven-build-compilation-error-failed-to-execute-goal-org-apache-maven-plugins/42525941#comment108501639_42525941
<build>..<configuration>..<source>1.8</source><target>1.8</target>
但し、生成されたmanifestの中に見ると、 「Build-Jdk: 1.8」
これはおかしいと思った。。。eclipseの中、projectを右クリック、properties, Java compilerを12に設定しているのに、何でやろうと
解決:上記プロジェクトのpropertiesだけじゃ帰ると足りない。
eclipseのwindow→properties→Java→Installed JRE's で、
java12を設定しないといけなかった。jre1.8版を指していたからだ
~~~~
単純なmavenプロジェクトを作った
内容:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>guru.springframework</groupId>
<artifactId>hello-world</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>12</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.8.1</version>
</dependency>
</dependencies>
</project>
→ clrでは、mvn clean package が成功する
生成されるmanifestのでは、 「Build-Jdk: 12.0.2」
→ Pathに指定しているjdkは12だから
しかし、eclipseで同じプロジェクトを clean package をしようとすると
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project hello-world: Fatal error compiling: 12は無効なターゲット・リリースです -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project hello-world: Fatal error compiling
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:215)
。。。
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
調べたところ、以下の人気ある回答で一応ビルドできた
https://stackoverflow.com/questions/42525139/maven-build-compilation-error-failed-to-execute-goal-org-apache-maven-plugins/42525941#comment108501639_42525941
<build>..<configuration>..<source>1.8</source><target>1.8</target>
但し、生成されたmanifestの中に見ると、 「Build-Jdk: 1.8」
これはおかしいと思った。。。eclipseの中、projectを右クリック、properties, Java compilerを12に設定しているのに、何でやろうと
解決:上記プロジェクトのpropertiesだけじゃ帰ると足りない。
eclipseのwindow→properties→Java→Installed JRE's で、
java12を設定しないといけなかった。jre1.8版を指していたからだ
Comments
Post a Comment