gpt4 book ai didi

java - Maven项目安装: invalid target release: 1. 7错误

转载 作者:行者123 更新时间:2023-12-02 04:14:08 24 4
gpt4 key购买 nike

当我尝试使用 Maven 安装项目时遇到此错误。我读了很多帖子,说这个错误是因为maven正在使用另一个版本的java,但这不是我的情况(我认为),因为我运行的每个命令都说使用的版本是java 1.7。

这是终端的结果:

Maven installation error:
Failure executing javac, but could not parse the error:
javac: invalid target release: 1.7
Usage: javac <options> <source files>
use -help for a list of possible options

mvn -version 的输出

Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 12:22:22-0300)
Maven home: /Applications/Dev/apache-maven-3.3.3
Java version: 1.7.0_79, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.11.1", arch: "x86_64", family: "mac"

Java 主页:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home

pom.xml(编译器插件部分):

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>

在我看来一切都很好,但不断出现错误。

最佳答案

maven-compiler-plugin 版本更新为 3.3:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version> <!-- HERE -->
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>

JAVA_HOME是如何设置的?

Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre

看起来您需要将其更正为 /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/

Why I am not able to see the JAVA_HOME path on my MAC OS X 10.11?

关于java - Maven项目安装: invalid target release: 1. 7错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33499716/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com