使用Eclipse + Tomcat,要使用熱加載,總是會重啟tomcat webapp。
可以使用這個插件:jrebel
如果是Tomcat 7.0+版本,需要使用jrebel5.5.1+的版本,不然總會報一些錯誤。
使用方法:
1) 下載jrebel 5.5.1+
2) 右鍵項目,選擇:
3) 找到"VM arguments":
里頭填入:
-Dcatalina.base="E:\JavaProject\.metadata\.plugins\org.eclipse.wst.server.core\tmp0" -Dcatalina.home="D:\Program Files\apache-tomcat-7.0.54" -Dwtp.deploy="E:\JavaProject\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps" -Djava.endorsed.dirs="D:\Program Files\apache-tomcat-7.0.54\endorsed" -noverify -javaagent:F:\Tools\Java\jrebel\jrebel.jar -Drebel.dirs=E:\JavaProject\obs\WebContent\WEB-INF\classes -Drebel.spring_plugin=true -Drebel.struts2-plugin=true
說明:
-noverify:解壓的jrebel.jar文件地址
-Drebel.dirs:項目編譯的classes地址
-Drebel.spring_plugin:使用了spring,設為true
-Drebel.struts2-plugin:使用了struts,設為true
4) 把eclipse的tomcat啟用自動加載功能停了,以防止它總是自動重啟tomcat
好了,現在修改一個java方法,保存試試。
其實,tomcat使用Run Debug方式也可以達到這樣的效果: