报错信息
D:\workspace\jdk1.8.0_321\bin\java.exe -Dmaven.multiModuleProjectDirectory=D:\workspace\demo “-Dmaven.home=D:\JetBrains\IntelliJ IDEA 2021.2.1\plugins\maven\lib\maven3” “-Dclassworlds.conf=D:\JetBrains\IntelliJ IDEA 2021.2.1\plugins\maven\lib\maven3\bin\m2.conf” “-Dmaven.ext.class.path=D:\JetBrains\IntelliJ IDEA 2021.2.1\plugins\maven\lib\maven-event-listener.jar” “-javaagent:D:\JetBrains\IntelliJ IDEA 2021.2.1\lib\idea_rt.jar=50185:D:\JetBrains\IntelliJ IDEA 2021.2.1\bin” -Dfile.encoding=UTF-8 -classpath “D:\JetBrains\IntelliJ IDEA 2021.2.1\plugins\maven\lib\maven3\boot\plexus-classworlds-2.6.0.jar;D:\JetBrains\IntelliJ IDEA 2021.2.1\plugins\maven\lib\maven3\boot\plexus-classworlds.license” org.codehaus.classworlds.Launcher -Didea.version=2021.2.1 -s D:\workspace\apache-maven-3.9.5\conf\settings.xml package
[WARNING]
[WARNING] Some problems were encountered while building the effective settings
[WARNING] Unrecognised tag: ‘blocked’ (position: START_TAG seen …\n … @165:16) @ D:\workspace\apache-maven-3.9.5\conf\settings.xml, line 165, column 16
[WARNING]
[INFO] Scanning for projects…
[INFO]
[INFO] --------------------------< com.example:demo >--------------------------
[INFO] Building demo 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] — maven-resources-plugin:3.3.1:resources (default-resources) @ demo —
[INFO] Copying 1 resource from src\main\resources to target\classes
[INFO] Copying 0 resource from src\main\resources to target\classes
[INFO]
[INFO] — maven-compiler-plugin:3.11.0:compile (default-compile) @ demo —
[INFO] Changes detected - recompiling the module! :source
[INFO] Compiling 1 source file with javac [debug release 1.8] to target\classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.930 s
[INFO] Finished at: 2023-11-24T18:26:48+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (default-compile) on project demo: Fatal error compiling: 无效的标记: --release -> [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
Process finished with exit code 1
问题原因
版本不兼容
spring boot版本跟jdk版本不兼容
我使用是spring boot版本3.16
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.6</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
jdk1.8
解决方案
1.升级jdk版本为11或以上
2.减低spring boot版本
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>