首页 > 其他 > 详细

tomcat启动以及运行时部署应用

时间:2015-10-18 14:01:27      阅读:489      评论:0      收藏:0      [点我收藏+]

1. 在tomcat启动时部署web应用

翻译:http://tomcat.apache.org/tomcat-7.0-doc/deployer-howto.html#Deployment_on_Tomcat_startup

Deployment on Tomcat startup

If you are not interested in using the Tomcat Manager, or TCD, then you‘ll need to deploy your web applications statically to Tomcat, followed by a Tomcat startup. The location you deploy web applications to for this type of deployment is called the appBase which is specified per Host. You either copy a so-called exploded web application, i.e non-compressed, to this location, or a compressed web application resource .WAR file.

【如果你对使用Tmocat Manager或者TCD部署web应用不感兴趣,那么你可以把解压之后的web应用或者war包放到对应Host的appBase目录下,这样它们就会随着tomcat的启动而被部署到服务器】

The web applications present in the location specified by the Host‘s (default Host is "localhost") appBase attribute (default appBase is "$CATALINA_BASE/webapps") will be deployed on Tomcat startup only if the Host‘s deployOnStartup attribute is "true".

【只有当<Host>中的deployOnStartup属性是true的时候,该Host对应appBase下的web应用才会随着tomcat的启动而被部署到服务器。默认的Host是localhost,默认的appBase路径是$CATALINA_BASE/webapps(注:deployOnStartup默认就是true)】

The following deployment sequence will occur on Tomcat startup in that case:

【tomcat启动时,部署的顺序如下:】

Any Context Descriptors will be deployed first.

【Context文件会被首先部署】

The locations for Context Descriptors are:

$CATALINA_BASE/conf/[enginename]/[hostname]/[webappname].xml

$CATALINA_BASE/webapps/[webappname]/META-INF/context.xml

【Context文件路径为:$CATALINA_BASE/conf/[enginename]/[hostname]/[webappname].xml以及$CATALINE_BASE/webapps/[webappname]/META-INF/context.xml】

Exploded web applications not referenced by any Context Descriptor will then be deployed. Note that if an exploded web application has an associated .WAR file in the appBase, Tomcat will not detect if the associated .WAR has been updated while Tomcat was stopped and will deploy the exploded web application as is. The exploded web application will not be removed and replaced with the contents of the updated .WAR file.

【接着部署的是在Context文件中没有涉及到的,且已经被解压的web应用。要注意的是,如果解压的web应用在appBase目录下还有一个相对应的.war文件,tomcat并不会检测该war文件在tomcat停止后是否进行过更新,而是依旧显示解压后的web应用,并且解压后的web应用的内容也不会随着war文件的更新而改变

注:要注意的是,此处指的是tomcat停止后如果对war包进行了更新,那么再次启动tomcat,显示的依旧是原来的那个web应用。但是如果是在tomcat运行时对war包进行了更新,那么tomcat也会检测到,并显示出更新后的结果,这一点可以在下面的"tomcat运行时部署"中体现出来】

.WAR files will be deployed

【最后部署的是.war文件】

 

总结:tomcat启动时部署顺序如下:

1.部署Context文件。Context文件的路径为:$CATALINA_BASE/conf/[enginename]/[hostname]/[webappname].xml以及$CATALINE_BASE/webapps/[webappname]/META-INF/context.xml

2.部署appBase下已经被解压的web应用

3.部署appBase下的.war文件

注:部署appBase下的已解压web应用以及.war文件,指的是appBase/这一级目录,不包括其他的子目录,也就是说,除了appBase/这一级目录下的web应用以及.war文件会被自动部署之外,其他的web应用以及.war文件不会被自动部署(.war文件也不会被自动解压)

 

2.在tomcat运行时部署

翻译:http://tomcat.apache.org/tomcat-7.0-doc/deployer-howto.html

Deploying on a running Tomcat server

It is possible to deploy web applications to a running Tomcat server.

【在tomcat运行时也可以部署web应用】

If the Host autoDeploy attribute is "true", the Host will attempt to deploy and update web applications dynamically, as needed, for example if a new .WAR is dropped into the appBase. For this to work, the Host needs to have background processing enabled which is the default configuration.

【如果主机的autoDeploy属性被设置为true,那么该主机在需要时会尝试动态的部署和更新web应用,比如,如果一个appBase中添加了一个新的.war文件,则该主机就会动态解压并部署该web应用。为了实现这个目的,主机必须有一个具有默认配置的后台进程】

 autoDeploy set to "true" and a running Tomcat allows for:

【如果autoDeploy被置为true,则tomcat运行时会允许以下操作:】

Deployment of .WAR files copied into the Host appBase.

【部署添加到appBase下的.war文件】

Deployment of exploded web applications which are copied into the Host appBase.

【部署添加到appBase下的已经解压的web应用】

Re-deployment of a web application which has already been deployed from a .WAR when the new .WAR is provided. In this case the exploded web application is removed, and the .WAR is expanded again. Note that the explosion will not occur if the Host is configured so that .WARs are not exploded with a unpackWARs attribute set to "false", in which case the web application will be simply redeployed as a compressed archive.

【在tomcat运行时,如果解压的web应用在appBase目录下还有一个相对应的.war文件,且该.war文件被更新了,此时,原先的web应用被移除,对应的更新后的.war文件会被再次解压并部署。需要注意的是,如果主机的unpackWars属性被设置为false,此时tomcat只会重新部署已经解压的web应用,而不会像前面所说的那样,对.war文件进行解压并部署】

Re-loading of a web application if the /WEB-INF/web.xml file (or any other resource defined as a WatchedResource) is updated.

【如果/WEB-INF/web.xml文件或者任何被定义为WatchedResource的资源更新了,则对应的web应用会被重新部署】

 Re-deployment of a web application if the Context Descriptor file from which the web application has been deployed is updated.

【如果Context文件被更新了,则对应的web应用也会被重新部署】

Re-deployment of dependent web applications if the global or per-host Context Descriptor file used by the web application is updated.

Re-deployment of a web application if a Context Descriptor file (with a filename corresponding to the Context path of the previously deployed web application) is added to the $CATALINA_BASE/conf/[enginename]/[hostname]/ directory.

【如果$CATALINA_BASE/conf/[enginename]/[hostname]/目录下添加了一个Context文件,则web应用会被重新部署】

Undeployment of a web application if its document base (docBase) is deleted. Note that on Windows, this assumes that anti-locking features (see Context configuration) are enabled, otherwise it is not possible to delete the resources of a running web application.

【如果一个web应用的docBase被删除,则该web应用被卸载】

Note that web application reloading can also be configured in the loader, in which case loaded classes will be tracked for changes.

【注意,也可以在加载器中配置web应用的重新部署,在这种情况下,被加载的类中发生的改变会被追踪到】

 

总结:tomcat运行时部署如下:

1.在appBase下新增的web应用会被部署

2.在appBase下新增的.war文件会被部署

3.在$CATALINA_BASE/conf/[enginename]/[hostname]/目录下新增的Context文件中对应的web应用会被部署

4.如果Context文件被更新,则对应的web应用会被重新部署

5.如果.war文件被更新,则对应的解压后的web应用会被重新部署

6.如果/WEB-INF/web.xml文件或者任何被定义为WatchedResource的资源更新了,则对应的web应用会被重新部署

tomcat启动以及运行时部署应用

原文:http://www.cnblogs.com/kevinq/p/4889304.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!