Tomcat 7.x热部署

由于在开发阶段,需要频繁的修改源代码,如果每次修改完代码都去重启服务器来检测效果,那简直麻烦到你想死,又耽误时间,所以,在网上找了许久,终于找到了解决办法, 特来分享

我也试了修改Server.xml配置文件的,但是设置了reloadable="true"属性还是不太好使,就在<Context>配置中修改成对所有的项目均有效。

(1) 修改Tomcat 7.x安装目录下的conf下的context.xml,在<Context>节点上添加reloadable="true"属性。

<Context reloadable="true">
         //中间数据不用修改
< /Context>

(2) 进入myEclipse - > preference -> Tomcat 7.x -> JDK , 在Optional Java VM arguments中填入 -Dcom.sun.management.jmxremote=true 如下图:

(3)部署完成。

Note:这种方式的热部署,不仅代码类文件会自动部署,配置类文件的修改也会自动部署,可以大大节省开发等待时间。

--->注意:后来在这种配置后遇到了一些内存溢出的问题- -!!

严重: The web application [/day21_1] created a ThreadLocal with key of type [com.sun.faces.util.Util$1] (value [com.sun.faces.util.Util$1@334af6e7]) and a value of type [java.util.HashMap] (value [{com.sun.faces.patternCache={ = }}]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Exception in thread "ContainerBackgroundProcessor[StandardEngine[Catalina]]"
java.lang.OutOfMemoryError: PermGen space

解决方式:解决方法: 手动设置MaxPermSize大小修改

TOMCAT_HOME/bin/catalina.sh在echo "Using CATALINA_BASE:   $CATALINA_BASE"上面加入以下行:JAVA_OPTS="-server -XX:PermSize=64M -XX:MaxPermSize=128m建议:将相同的第三方jar文件移置到tomcat/shared/lib目录下,这样可以达到减少jar 文档重复占用内存的目的。

原文地址:https://www.cnblogs.com/hushuai1314/p/6258810.html