【服务器_Tomcat】Tomcat的Server Options选项

一、配置

默认前两个是没有勾选的,应该勾选上:

在Cotext节点中有一个reloadable='true'属性,将它改为false,可以在修改java文件后不用重启服务器即可生效,但是不包括新建java文件、添加方法和变量的操作

为了在开发时,让tomcat能够自动重新加载,我们修改过的代码和配置,需要对Tomcat的context.xml文件进行设置。

在<context>标签中,加上reloadable属性,并且将值设为true 

  1. <Context reloadable="true">  
  2.     <!--注意: reloadable设为true,目的是为了方便开发阶段, 它会影响tomcat性能;当在正式部署服务时,需要改成false -->  

二、浏览文件

Context节点单独生成的文件:

原来Tomcat安装目录下conf/server.xml中的Context节点(勾选第二个选项之后,server.xml中就不存在这个节点了):

<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">
    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t &quot;%r&quot; %s %b" prefix="localhost_access_log" suffix=".txt"/>
    <Context docBase="D:\workspace\workspace(eclipse)\Shop\WebContent" path="/Shop" reloadable="true" source="org.eclipse.jst.jee.server:Shop">
        <Resources>
            <PreResources base="D:\workspace\workspace(eclipse)\Shop\build\classes" classLoaderOnly="false" className="org.apache.catalina.webresources.DirResourceSet" internalPath="/" webAppMount="/WEB-INF/classes"/>
        </Resources>
    </Context>
</Host>

三、原因

1.勾选第一个是为了防止出现警告:

警告: A docBase D:/Tomcat/webapps/Shop inside the host appBase has been specified, and will be ignored

勾选后表示让tomcat直接使用eclipse中的WebContent下的东西
省去publish到<workspace>.metadata.pluginsorg.eclipse.wst.server.coretmp0webapps
并将tmp0webapps下相关的resources删除,
同时会修改<workspace>.metadata.pluginsorg.eclipse.wst.server.coreservers.xml中的serveModulesWithoutPublish=true以及tmp0/conf/server.xml中的<Context>配置

2.勾选第二个是为了防止出现警告:

警 告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:strut2demo' did not find a matching property.

[SetPropertiesRule]警告的原因是Tomcat6.0以上的server.xml的context节点中不再支持source属性了。具体说明如下:

For Tomcat 6, unlike Tomcat 4.x, it is NOT recommended to place <Context> elements directly in the server.xml file. This is because it makes modifying the Context configuration more invasive since the main conf/server.xml file cannot be reloaded without restarting Tomcat.

posted @ 2016-12-26 18:38  多弗朗明哥  阅读(3894)  评论(0编辑  收藏  举报