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

IntelliJ IDEA运行项目时连接超时且JDK版本不符求助

解决IntelliJ IDEA编译失败(连接超时+JDK版本不匹配)

一、强制使用JDK 1.8编译(解决版本设置不生效问题)

需逐一检查以下配置节点,确保全链路统一使用JDK 1.8:

  • 全局SDK配置:File → Project Structure → Platform Settings → SDKs,确认已添加JDK 1.8,若存在多个SDK可设为默认。
  • 项目级配置:File → Project Structure → Project Settings → Project,将Project SDK和Project language level均设置为JDK 1.8对应选项(如8 - Lambdas, type annotations etc.)。
  • 模块级配置:File → Project Structure → Project Settings → Modules,逐个模块检查,将Module SDK设为JDK 1.8,同步调整Language Level为8。
  • 编译器配置:File → Settings → Build, Execution, Deployment → Compiler → Java Compiler,在Per-module bytecode version中,将所有模块的Target bytecode version设为1.8;若为构建工具项目:
    • Gradle:在build.gradle中确保sourceCompatibility = 1.8、targetCompatibility = 1.8,并指定jdkHome指向JDK 1.8路径。
    • Maven:在pom.xml的maven-compiler-plugin节点中设置<source>1.8</source>和<target>1.8</target>。
  • IDEA启动JDK(可选):若IDEA自身JDK干扰编译,可在idea64.exe.vmoptions中添加-Djdk.home=C:\Program Files\Java\jdk1.8.xxx(替换为实际JDK 1.8路径)。

二、解决编译连接超时与权限异常

日志中的module java.base does not "opens java.lang" to unnamed module异常是JDK版本不匹配导致的模块系统冲突,修复JDK版本后该异常会自动消失。针对连接超时问题:

  • 重置编译缓存:File → Invalidate Caches...,勾选Clear file system cache and local history,点击Invalidate and Restart。
  • 排查端口占用:打开命令提示符,执行netstat -ano | findstr :59297(替换为日志中出现的端口号),若有进程占用该端口,结束对应进程后重新编译。
  • 临时关闭安全软件:关闭Windows防火墙或第三方安全软件,排除本地连接被拦截的可能。
  • 调整编译内存:File → Settings → Build, Execution, Deployment → Compiler,调大Build Process Heap Size至1024m或更高,避免内存不足导致编译进程崩溃。
  • 禁用增量编译:取消勾选Build project automatically,改用Build → Rebuild Project执行全量编译。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.13 11:32:01