Eclipse 部署項目到 Tomcat 時彈出:The selected server is enabled, but is not configured properly. Deployment to it will not be permitted until the problem is corrected. Please navigate to the server preference pages and verify the field with the prompt: Tomcat JDK name
Eclipse 無法識別 Tomcat 綁定的 JDK,通常由以下原因導致:
JAVA_HOME/CATALINA_HOME 衝突# Windows echo %JAVA_HOME% # 應指向 JDK 根目錄(如 C:\Java\jdk1.8.0_202) echo %PATH% # 包含 %JAVA_HOME%\bin # Linux/Mac echo $JAVA_HOME echo $PATH
⚠️ 刪除 CATALINA_HOME:若存在,請刪除,避免干擾 Eclipse 內置 Tomcat 解析。
路徑:Window → Preferences → Java → Installed JREs
Edit 檢查 JRE home 指向 JDK 根目錄tools.jar(JDK 特有)路徑:Window → Preferences → Server → Runtime Environments
Edit右鍵項目 → Properties → Java Compiler:
Compiler compliance level = JDK 版本(如 1.8)Generated .class files compatibility 同步右鍵項目 → Properties → Java Build Path → Libraries:
JRE System Library 指向 Workspace default JRE (jdk1.8.x)若上述無效,檢查 server.xml 端口是否被佔用:
命令檢查:netstat -ano | findstr :8080(Windows)或 lsof -i:8080(Linux)。
Servers 視圖右鍵 Tomcat → Clean → Clean Tomcat Work Directory