Maven - JAVA_HOME 位置和执行 javac 的编译失败
Maven - JAVA_HOME location and Compilation failure executing javac
---可跳过部分---
大家好,第一次来这里,希望我不是在写任何其他东西的克隆。我花了几天时间寻找像我这样的案例,但我尝试过的所有方法都失败了,或者无法简单地为我找到正确的解决方案。
我正在尝试在另一名学生的项目中使用 Maven(必须继续他已经做过的)学校项目,在 Ubuntu 14.04 的电脑上。我在从 github 下载的项目目录中,我需要创建一个 .war 文件并将其用于 Tomcat。
我是跟着那位学生的向导走的,可能我有点不知道该怎么做。
---tl:dr 我需要帮助---
所以当我启动 mvn -version 时,我得到这个:
Java version: 1.7.0_101, vendor: Oracle Corporation Java home:
/usr/lib/jvm/java-7-openjdk-amd64/jre Default locale: it_IT, platform
encoding: UTF-8 OS name: "linux", version: "3.19.0-58-generic", arch:
"amd64", family: "unix"
几天前,我遇到了 $JAVA_HOME 环境变量的问题,可能通过管理 /etc/environment 文件解决了它,事实上我没有收到任何关于此的错误。现在,当我执行 mvn package 时,我得到
[INFO] Scanning for projects... [INFO]
[INFO]
------------------------------------------------------------------------ [INFO] Building GWT Maven Archetype 2.6.0-SNAPSHOT [INFO]
------------------------------------------------------------------------ [INFO] [INFO] --- maven-enforcer-plugin:1.3.1:enforce
(enforce-versions) @ webprotege --- [INFO] [INFO] ---
gwt-maven-plugin:2.7.0:generateAsync (default) @ webprotege --- [INFO]
[INFO] --- build-helper-maven-plugin:1.8:add-source (add-source) @
webprotege --- [INFO] Source directory:
/home/wapaolo/Documenti/data/webprotege/webprotege/target/generated-sources/gwt
added. [INFO] [INFO] --- maven-resources-plugin:2.3:resources
(default-resources) @ webprotege --- [INFO] Using 'UTF-8' encoding to
copy filtered resources. [INFO] Copying 10 resources [INFO] [INFO]
--- maven-compiler-plugin:2.3.2:compile (default-compile) @ webprotege --- [INFO] Compiling 1744 source files to /home/wapaolo/Documenti/data/webprotege/webprotege/target/webprotege-2.6.0-SNAPSHOT/WEB-INF/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : [INFO]
------------------------------------------------------------- [ERROR] Failure executing javac, but could not parse the error: javac: invalid
target release: 1.8 Usage: javac use -help
for a list of possible options
[INFO] 1 error [INFO]
------------------------------------------------------------- [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO]
------------------------------------------------------------------------ [INFO] Total time: 5.241s [INFO] Finished at: Mon May 09 16:54:04 CEST
2016 [INFO] Final Memory: 18M/295M [INFO]
------------------------------------------------------------------------ [ERROR] Failed to execute goal
org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile
(default-compile) on project webprotege: Compilation failure [ERROR]
Failure executing javac, but could not parse the error: [ERROR] javac:
invalid target release: 1.8 [ERROR] Usage: javac [ERROR] use -help for a list of possible options [ERROR] ->
[Help 1] [ERROR] [ERROR] To see the full stack trace of the errors,
re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X
switch to enable full debug logging. [ERROR] [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/MojoFailureException
那么我现在应该怎么做才能继续?我不知道..
您的 Maven 项目需要 java 1.8,但您的编译器是 1.7。在 pom.xml
文件中查找类似
的内容
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
并将其更改为 1.7 或下载 1.8 jdk。
---可跳过部分---
大家好,第一次来这里,希望我不是在写任何其他东西的克隆。我花了几天时间寻找像我这样的案例,但我尝试过的所有方法都失败了,或者无法简单地为我找到正确的解决方案。
我正在尝试在另一名学生的项目中使用 Maven(必须继续他已经做过的)学校项目,在 Ubuntu 14.04 的电脑上。我在从 github 下载的项目目录中,我需要创建一个 .war 文件并将其用于 Tomcat。 我是跟着那位学生的向导走的,可能我有点不知道该怎么做。
---tl:dr 我需要帮助---
所以当我启动 mvn -version 时,我得到这个:
Java version: 1.7.0_101, vendor: Oracle Corporation Java home: /usr/lib/jvm/java-7-openjdk-amd64/jre Default locale: it_IT, platform encoding: UTF-8 OS name: "linux", version: "3.19.0-58-generic", arch: "amd64", family: "unix"
几天前,我遇到了 $JAVA_HOME 环境变量的问题,可能通过管理 /etc/environment 文件解决了它,事实上我没有收到任何关于此的错误。现在,当我执行 mvn package 时,我得到
[INFO] Scanning for projects... [INFO]
[INFO] ------------------------------------------------------------------------ [INFO] Building GWT Maven Archetype 2.6.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-enforcer-plugin:1.3.1:enforce (enforce-versions) @ webprotege --- [INFO] [INFO] --- gwt-maven-plugin:2.7.0:generateAsync (default) @ webprotege --- [INFO] [INFO] --- build-helper-maven-plugin:1.8:add-source (add-source) @ webprotege --- [INFO] Source directory: /home/wapaolo/Documenti/data/webprotege/webprotege/target/generated-sources/gwt added. [INFO] [INFO] --- maven-resources-plugin:2.3:resources (default-resources) @ webprotege --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 10 resources [INFO] [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ webprotege --- [INFO] Compiling 1744 source files to /home/wapaolo/Documenti/data/webprotege/webprotege/target/webprotege-2.6.0-SNAPSHOT/WEB-INF/classes [INFO] ------------------------------------------------------------- [ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] Failure executing javac, but could not parse the error: javac: invalid target release: 1.8 Usage: javac use -help for a list of possible options[INFO] 1 error [INFO] ------------------------------------------------------------- [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 5.241s [INFO] Finished at: Mon May 09 16:54:04 CEST 2016 [INFO] Final Memory: 18M/295M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project webprotege: Compilation failure [ERROR] Failure executing javac, but could not parse the error: [ERROR] javac: invalid target release: 1.8 [ERROR] Usage: javac [ERROR] use -help for a list of possible options [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [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/MojoFailureException
那么我现在应该怎么做才能继续?我不知道..
您的 Maven 项目需要 java 1.8,但您的编译器是 1.7。在 pom.xml
文件中查找类似
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
并将其更改为 1.7 或下载 1.8 jdk。