问题描述
今天在导入thymeleaf官网上的example项目时,在导入项目后clean,之后mvn compile出现问题。
项目地址:
https://github.com/thymeleaf/thymeleafexamples-gtvg
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project gtvg: Fatal error compilin
g: 错误: 不支持发行版本 6 -> [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
问题所在:
项目中pom.xml设置的 java即jdk版本不支持该插件 org.apache.maven.plugins:maven-compiler-plugin:3.8.1
解决办法:
更改pom.xml中java版本
初始:
<properties>
<java.version>6</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<maven.compiler.release>${java.version}</maven.compiler.release>
<project.build.sourceEncoding>US-ASCII</project.build.sourceEncoding>
<thymeleaf.version>3.0.11.RELEASE</thymeleaf.version>
</properties>
更改为
<properties>
<java.version>11</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<maven.compiler.release>${java.version}</maven.compiler.release>
<project.build.sourceEncoding>US-ASCII</project.build.sourceEncoding>
<thymeleaf.version>3.0.11.RELEASE</thymeleaf.version>
</properties>
更改这个地方即可:<java.version>11</java.version>