You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

IntelliJ运行Spring Boot报错java: invalid source release:15,已设Java11求解决

解决Java: invalid source release: 15错误(已配置Java11但编译失败)

以下是针对性的排查和解决步骤:

1. 完善Maven编译器插件配置

仅在<properties>中指定java.version可能不够,部分Spring Boot版本或Maven环境会默认使用更高的JDK版本编译。需要在pom.xml中显式配置maven-compiler-plugin,强制指定源码和目标版本:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version> <!-- 使用适配的插件版本即可 -->
            <configuration>
                <source>${java.version}</source>
                <target>${java.version}</target>
                <release>${java.version}</release> <!-- Java 9+推荐使用release参数统一管控版本 -->
            </configuration>
        </plugin>
    </plugins>
</build>

修改后执行mvn clean compile验证编译是否正常。

2. 检查IntelliJ的Run/Debug配置

  • 打开Run -> Edit Configurations
  • 找到你的Spring Boot应用配置,切换到Configuration标签页
  • 确认JRE选项选择的是corretto-11,而非其他JDK版本

3. 核对IntelliJ全局编译器设置

  • 打开File -> Settings -> Build, Execution, Deployment -> Compiler -> Java Compiler
  • 确认Project bytecode version设置为11
  • 检查下方模块列表中spring_chat的Target bytecode version是否为11,若不一致则手动修改

4. 清理IntelliJ缓存并重启

缓存冲突可能导致配置不生效:

  • 执行File -> Invalidate Caches...
  • 选择Invalidate and Restart,等待IDE重启后重新编译项目

内容的提问来源于stack exchange,提问作者densal03

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.18 13:17:07