报错: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版本试试。