解决Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile(default-compile)

报错:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project test01-hello-mybatis: Fatal error compiling: 错误: 无效的目标发行版:12.0.2 -> [Help 1]

在这里插入图片描述
在这里插入图片描述
官方帮助文档:

Unlike many other errors, this exception is not generated by the Maven core itself but by a plugin. As a rule of thumb, plugins use this error to signal a problem in their configuration or the information they retrieved from the POM.

The concrete meaning of the exception depends on the plugin so please have a look at its documentation. The documentation for many common Maven plugins can be reached via our plugin index.

翻译:
与许多其他错误不同,这个异常不是由 maven 内核本身生成的,而是由插件生成的。作为一个经验法则,插件使用这个错误信号的配置问题或信息,他们从 pom 检索。异常的具体含义取决于插件,所以请查看它的文档。许多常见的 maven 插件的文档可以通过我们的插件索引访问。

解决方案

指定编译的JDK版本,在项目依赖中修改以下信息:

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>12.0.2</maven.compiler.source>
    <maven.compiler.target>12.0.2</maven.compiler.target>
  </properties>

将其JDK版本改为

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>12</maven.compiler.source>
    <maven.compiler.target>12</maven.compiler.target>
  </properties>

其它版本的jdk解决方案类似。
如果该解决方案无法解决可参考其他博客,

file–>settings–> Build, Execution, Deployment–>Build Tools–>Maven–>runner
或者Build, Execution, Deployment–>compile–>Java Compile里面的jdk版本修改为自己本地的jdk版本试试。

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值