一、配置
默认前两个是没有勾选的,应该勾选上:
在Cotext节点中有一个reloadable='true'属性,将它改为false,可以在修改java文件后不用重启服务器即可生效,但是不包括新建java文件、添加方法和变量的操作
二、浏览文件
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 "%r" %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.