tomcat的热加载与热部署

名词解释:

热部署 autoDeploy : 当context XML改变的时候,会直接部署到tomcat上,而不用重启tomcat。假设tomcat下面多加了一个应用,tomcat会自动部署这个应用,不用重新启动。

     autoDeploy:This flag value indicates if Tomcat should check periodically for new or updated web applications while Tomcat is running. If true, Tomcat periodically checks the appBase and xmlBase directories and deploys any new web applications or context XML descriptors found. Updated web applications or context XML descriptors will trigger a reload of the web application. The flag's value defaults to true. See Automatic Application Deployment for more information.

热加载 reloadable : 如果【/WEB-INF/classes/】或者/WEB-INF/lib 下面有变化,tomcat会重新加载整个web应用。

  reloadable:Set to true if you want Catalina to monitor classes in /WEB-INF/classes/ and /WEB-INF/lib for changes, and automatically reload the web application if a change is detected. This feature is very useful during application development, but it requires significant runtime overhead and is not recommended for use on deployed production applications. That's why the default setting for this attribute is false. You can use the Manager web application, however, to trigger reloads of deployed applications on demand.

实现热加载的方式

修改的文件:apache-tomcat/conf/server.xml 

修改内容:标签中添加 如下 标签 

<Context debug="0" path="/platform" docBase="D:/tomcat-7.0.68/webapps/platform" reloadable="true"/>

解释: 

debug:表示log中记录异常的控制等级,数值越大,记录越详细。 
path:   访问目录 此例即 127.0.0.1/mytest/ 
docBase:项目目录 可以为绝对路径(注意 ‘/’ 方向),也可以为相对路径(相对 webapps ,此例 docBase=”/mytest”) 
reloadable:字面意思可看出,是否加载新的class文件,实现热加载。

autoDeploy="true"    ----  自动部署

转载:http://blog.csdn.net/elapse008/article/details/51804473

原文地址:https://www.cnblogs.com/alisonGavin/p/7146072.html