
打开Project Structure ,查询Modules的项目jdk版本,发现项目中所有的模块的都变成了5了。
修改Maven地址\conf\setting.xml中设置默认jdk版本
我是用的jdk版本是17,已jdk17为例,修改如下:
<profile>
<id>developmentid>
<activation>
<jdk>17jdk>
<activeByDefault>trueactiveByDefault>
activation>
<properties>
<maven.compiler.source>17maven.compiler.source>
<maven.compiler.target>17maven.compiler.target>
<maven.compiler.compilerVersion>17maven.compiler.compilerVersion>
properties>
profile>
<profile>
<id>developmentid>
<activation>
<jdk>1.8jdk>
<activeByDefault>trueactiveByDefault>
activation>
<properties>
<maven.compiler.source>1.8maven.compiler.source>
<maven.compiler.target>1.8maven.compiler.target>
<maven.compiler.compilerVersion>1.8maven.compiler.compilerVersion>
properties>
profile>
参考文章:java错误:不支持发行版本5
SpringBoot使用了3.0或者3.0以上,因为Spring官方发布从Spring6以及SprinBoot3.0开始最低支持JDK17,所以仅需将SpringBoot版本降低为3.0.0以下即可。
本人用的jdk1.8版本,下图是必要的编译环境一致性的设置

<parent>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-parentartifactId>
<version>2.5.6version>
<relativePath/>
parent>