You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

执行mvn clean package报invalid target release: 1.8是什么含义?

报错含义解答

该报错属于项目预期使用Java 1.8作为编译目标版本,但当前运行Maven的Java环境版本和要求不匹配的情况,不是编译过程主动尝试使用Java 1.8导致的问题。

触发逻辑

maven-compiler-plugin会读取项目pom.xml中的配置,按指定的target版本生成对应兼容级别的字节码。当你配置的目标版本为1.8,但当前Maven绑定的JDK版本低于1.8时,低版本JDK没有能力生成更高版本的兼容字节码,就会抛出这个invalid target release的致命编译错误。

你收到的完整报错如下:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:compile (default-compile) on project protection: Fatal error compiling: invalid target release: 1.8 -> [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/MojoExecutionException

排查解决步骤

  • 首先在IntelliJ终端执行mvn -v命令,查看输出中Maven绑定的JDK版本,确认是否低于1.8
  • 如果是IDEA的Maven配置问题,可以进入File > Settings > Build, Execution, Deployment > Build Tools > Maven > Runner路径,将JRE选项调整为1.8或更高版本
  • 如果你不需要指定编译目标为1.8,也可以修改pom.xml中maven-compiler-plugin的source和target参数,和你本地可用的JDK版本保持一致

内容的提问来源于stack exchange,提问作者runnerpaul

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.23 16:45:02