JDK从11降级到8后IntelliJ IDEA无法运行Spring Boot Maven项目如何解决
解决方案:IntelliJ IDEA中Spring Boot Maven项目JDK11降级JDK8运行失败
- 修正Maven pom.xml全局编译配置
在pom.xml中添加/更新properties节点,指定编译版本为JDK8:
<properties> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties>
如果项目单独配置了maven-compiler-plugin插件,同步更新插件配置:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin>
- 校验Spring Boot版本兼容性
Spring Boot 3.0及以上版本最低要求JDK17,完全不支持JDK8,如果原项目使用3.x版本,需将Spring Boot版本降级到2.7.x系列及以下的兼容JDK8的版本。 - 清理缓存重新构建
- 点击IDEA顶部菜单栏
File -> Invalidate Caches... - 勾选清除文件系统缓存选项,执行失效并重启
- 重启后执行Maven
clean命令,再执行install命令重新构建项目
- 检查启动运行配置
打开IDEA右上角运行配置编辑页,找到对应Spring Boot启动项,确认运行使用的JRE版本为1.8。
内容的提问来源于stack exchange,提问作者KangDo
相关产品推荐
相关产品推荐

