一则奥、配置
默認(rèn)前兩個(gè)是沒(méi)有勾選的所踊,應(yīng)該勾選上:
在Cotext節(jié)點(diǎn)中有一個(gè)reloadable='true'屬性辉哥,將它改為false删铃,可以在修改java文件后不用重啟服務(wù)器即可生效耳贬,但是不包括新建java文件、添加方法和變量的操作
二猎唁、瀏覽文件
Context節(jié)點(diǎn)單獨(dú)生成的文件:
原來(lái)Tomcat安裝目錄下conf/server.xml中的Context節(jié)點(diǎn)(勾選第二個(gè)選項(xiàng)之后咒劲,server.xml中就不存在這個(gè)節(jié)點(diǎn)了):
<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.勾選第一個(gè)是為了防止出現(xiàn)警告:
警告: 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下相關(guān)的resources刪除诫隅,
同時(shí)會(huì)修改<workspace>.metadata.pluginsorg.eclipse.wst.server.coreservers.xml中的serveModulesWithoutPublish=true以及tmp0/conf/server.xml中的<Context>配置
2.勾選第二個(gè)是為了防止出現(xiàn)警告:
警 告: [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節(jié)點(diǎn)中不再支持source屬性了腐魂。具體說(shuō)明如下:
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.