1、設置
編輯catalina.bat,在
rem Guess CATALINA_HOME if not defined
set "CURRENT_DIR=%cd%"
if not "%CATALINA_HOME%" == "" goto gotHome
的上面插入以下內容
if ""%1"" == ""stop"" goto skip_config
SET CATALINA_OPTS=-server -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8787
:skip_config
其中,suspend=n表示tomcat啟動以后不會等待用戶debug連接,suspend=y表示會等待。
保存 catalina.bat。
2、啟動
你可以手動啟動startup.bat,這是及時生效的。也可以在eclipse里啟動tomcat,如果不生效就先用startup.bat啟動然后用eclipse調試一次,然后關閉tomcat,使用eclipse再次啟動tomcat時,debug會自動打開。