myeclipse更改后台代碼不用重啟tomcat的方法
方法1:
在WebRoot下的META-INF文件夾中新建一個名為context.xml文件,里面添加如下內容(要區分大小寫):
<Context reloadable = "true">:
</Context>
方法2:
在tomact的安裝目錄的conf文件中找到server.xml這個文件,在 </Host>結點的上面加上
<ContextdocBase="工程物理路徑"path="/工程名"reloadable="true"source="org.eclipse.jst.j2ee.server:工程名稱"/>
比如對於開發項目test:添加
<Context docBase="E:/apache-tomcat-6.0.24/webapps/test" path="/test" reloadable="true" source="org.eclipse.jst.j2ee.server:test"/>
conf/Context.xml是Tomcat公用的環境配置;若在server.xml中增加<Context path="/test" docBase="D:\test" debug="0" reloadable="false"/>的話,則myApp/META-INF/Context.xml就沒用了(被server.xml中的Context替代),
<Context>代表了運行在<Host>上的單個Web應用,一個<Host>可以有多個<Context>元素,每個Web應用必須有唯一的URL路徑,這個URL路徑在<Context>中的屬性path中設定。 <Context path="bbs" docBase="bbs" debug="0" reloadable="true"/>
<Context>元素的屬性:
一: path: 指定訪問該Web應用的URL入口。
二: docBase: 指定Web應用的文件路徑,可以給定絕對路徑,也可以給定相對於<Host>的appBase屬性的相對路徑,如果Web應用采用開放目錄結構,則指定Web應用的根目錄,如果Web應用是個war文件,則指定war文件的路徑。
三: reloadable: 如果這個屬性設為true,tomcat服務器在運行狀態下會監視在WEB-INF/classes和WEB-INF/lib目錄下class文件的改動,如果監測到有class文件被更新的,服務器會自動重新加載Web應用。
在開發階段將reloadable屬性設為true,有助於調試servlet和其它的class文件,但這樣用加重服務器運行負荷,建議在Web應用的發存階段將reloadable設為false。
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> <Context path="/ItcastOA" docBase="E:\apache-tomcat-6.0.30\webapps\ItcastOA" debug="0" reloadable="true" crossContext="true"/> </Host>
新技能 get