每次更改应用程序后都必须重新启动TomCat
我遇到了TomCat 7的问题,我对应用程序所做的任何更改,我使用ant构建,以查看这些更改,我必须不断重新启动服务器。只有当服务器关闭时,我才能构建和部署,然后重新启动服务器,它就会工作 如果我不重新启动服务器,并且我取消部署和部署应用程序,我将得到一个http:404错误 有人能告诉我我需要做什么,以避免每次更改时重新启动它 ANT构建文件:每次更改应用程序后都必须重新启动TomCat,tomcat,ant,Tomcat,Ant,我遇到了TomCat 7的问题,我对应用程序所做的任何更改,我使用ant构建,以查看这些更改,我必须不断重新启动服务器。只有当服务器关闭时,我才能构建和部署,然后重新启动服务器,它就会工作 如果我不重新启动服务器,并且我取消部署和部署应用程序,我将得到一个http:404错误 有人能告诉我我需要做什么,以避免每次更改时重新启动它 ANT构建文件: <?xml version="1.0"?> <project name="app" basedir="." default="u
<?xml version="1.0"?>
<project name="app" basedir="." default="usage">
<property file="build.properties"/>
<property name="src.dir" value="src"/>
<property name="web.dir" value="war"/>
<property name="build.dir" value="${web.dir}/WEB-INF/classes"/>
<property name="name" value="crimeTrack"/>
<path id="master-classpath">
<fileset dir="${web.dir}/WEB-INF/lib">
<include name="*.jar"/>
</fileset>
<fileset dir="${appserver.lib}">
<include name="servlet*.jar"/>
</fileset>
<pathelement path="${build.dir}"/>
</path>
<target name="usage">
<echo message=""/>
<echo message="${name} build file command list"/>
<echo message=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"/>
<echo message=" | Targets: ANT |"/>
<echo message=" ---------------------------------------------------"/>
<echo message=" | build --: Build the application |"/>
<echo message=" ---------------------------------------------------"/>
<echo message=" | deploy --: Deploy application as directory |"/>
<echo message=" ---------------------------------------------------"/>
<echo message=" | deploywar --: Deploy application as a WAR file |"/>
<echo message=" ---------------------------------------------------"/>
<echo message=" | install --: Install application in Tomcat |"/>
<echo message=" ---------------------------------------------------"/>
<echo message=" | reload --: Reload application in Tomcat |"/>
<echo message=" ---------------------------------------------------"/>
<echo message=" | start --: Start Tomcat application |"/>
<echo message=" ---------------------------------------------------"/>
<echo message=" | stop --: Stop Tomcat application |"/>
<echo message=" ---------------------------------------------------"/>
<echo message=" | list --: List Tomcat applications |"/>
<echo message=" ---------------------------------------------------"/>
<echo message=" ___________________________________________________"/>
<echo message=" Targets: Database "/>
<echo message=" ___________________________________________________"/>
<echo message=" | createTables --: Creates Database Tables |"/>
<echo message=" ---------------------------------------------------"/>
<echo message=" | emptyTables --: Empty Database Tables |"/>
<echo message=" ---------------------------------------------------"/>
<echo message=" | loadData --: Loads data into Database Tables |"/>
<echo message=" ---------------------------------------------------"/>
<echo message=" | showTables --: Lists the tables in Database |"/>
<echo message=" ---------------------------------------------------"/>
<echo message=" ___________________________________________________"/>
<echo message=" Targets: Junit "/>
<echo message=" ___________________________________________________"/>
<echo message=" | tests --: Runs test on all objects using JUNIT |"/>
<echo message= "${deploy.path}/${name} and ${build.dir}" />
<echo message=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"/>
</target>
<target name="build" description="Compile main source tree java files">
<mkdir dir="${build.dir}"/>
<javac destdir="${build.dir}" source="1.7" target="1.7" debug="true" includeantruntime="false"
deprecation="false" optimize="false" failonerror="true">
<src path="${src.dir}"/>
<classpath refid="master-classpath"/>
</javac>
</target>
<target name="deploy" depends="build" description="Deploy application">
<copy todir="${deploy.path}/${name}" preservelastmodified="true">
<fileset dir="${web.dir}">
<include name="**/*.*"/>
</fileset>
</copy>
</target>
<target name="deploywar" depends="build" description="Deploy application as a WAR file">
<war destfile="${name}.war"
webxml="${web.dir}/WEB-INF/web.xml">
<fileset dir="${web.dir}">
<include name="**/*.*"/>
</fileset>
</war>
<copy todir="${deploy.path}" preservelastmodified="true">
<fileset dir=".">
<include name="*.war"/>
</fileset>
</copy>
</target>
<!-- ============================================================== -->
<!-- Tomcat tasks -->
<!-- ============================================================== -->
<path id="catalina-ant-classpath">
<!-- We need the Catalina jars for Tomcat -->
<!-- * for other app servers - check the docs -->
<fileset dir="${appserver.lib}">
<include name="catalina-ant.jar"/>
</fileset>
</path>
<taskdef name="install" classname="org.apache.catalina.ant.DeployTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="list" classname="org.apache.catalina.ant.ListTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="start" classname="org.apache.catalina.ant.StartTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="stop" classname="org.apache.catalina.ant.StopTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<target name="install" description="Install application on the Tomcat Server">
<install url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}"
war="${name}"/>
</target>
<target name="reload" description="Reload application on the Tomcat Server">
<reload url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}"/>
</target>
<target name="start" description="Start Tomcat application">
<start url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}"/>
</target>
<target name="stop" description="Stop Tomcat application">
<stop url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}"/>
</target>
<target name="list" description="List Tomcat applications on server">
<list url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"/>
</target>
<!-- End Tomcat tasks -->
<!-- ============================================================== -->
<!-- TESTING JUNIT -->
<!-- ============================================================== -->
<property name="test.dir" value="test"/>
<path id="test-classpath">
<fileset dir="${web.dir}/WEB-INF/lib">
<include name="*.jar"/>
</fileset>
<pathelement path="${build.dir}"/>
<pathelement path="${test.dir}"/>
<pathelement path="${web.dir}/WEB-INF/classes"/>
</path>
<target name="buildtests" description="Compile test tree java files">
<mkdir dir="${build.dir}"/>
<javac destdir="${build.dir}" source="1.7" target="1.7" debug="true"
deprecation="false" optimize="false" failonerror="true">
<src path="${test.dir}"/>
<classpath refid="master-classpath"/>
</javac>
</target>
<target name="tests" depends="build, buildtests" description="Run tests">
<junit printsummary="on"
fork="false"
haltonfailure="false"
failureproperty="tests.failed"
showoutput="true">
<classpath refid="test-classpath"/>
<formatter type="brief" usefile="false"/>
<batchtest>
<fileset dir="${build.dir}">
<include name="**/*Tests.*"/>
<exclude name="**/Jdbc*Tests.*"/>
</fileset>
</batchtest>
</junit>
<fail if="tests.failed">
tests.failed=${tests.failed}
***********************************************************
***********************************************************
************* Testing Found Errors!... *************
***********************************************************
***********************************************************
</fail>
</target>
<target name="dbTests" depends="build, buildtests,emptyTables,createTables,loadData"
description="Run db tests">
<junit printsummary="on"
fork="false"
haltonfailure="false"
failureproperty="tests.failed"
showoutput="true">
<classpath refid="test-classpath"/>
<formatter type="brief" usefile="false"/>
<batchtest>
<fileset dir="${build.dir}">
<include name="**/Jdbc*Tests.*"/>
</fileset>
</batchtest>
</junit>
<fail if="tests.failed">
tests.failed=${tests.failed}
***********************************************************
***********************************************************
************* Testing Found Errors!... *************
***********************************************************
***********************************************************
</fail>
</target>
<target name="clean" description="Clean output directories">
<delete>
<fileset dir="${build.dir}">
<include name="**/*.class"/>
</fileset>
</delete>
</target>
<target name="undeploy" description="Un-Deploy application">
<delete>
<fileset dir="${deploy.path}/${name}">
<include name="**/*.*"/>
</fileset>
</delete>
</target>
<!-- ============================================================== -->
<!-- DataBase CrimeTrack -->
<!-- ============================================================== -->
<target name="createTables">
<echo message="CREATE TABLES USING: ${db.driver} ${db.url}"/>
<sql driver="${db.driver}"
url="${db.url}"
userid="${db.user}"
password="${db.pw}"
onerror="continue"
src="db/create_database_tables.sql">
<classpath refid="master-classpath"/>
</sql>
</target>
<target name="emptyTables">
<echo message="EMPTY TABLES USING: ${db.driver} ${db.url}"/>
<sql driver="${db.driver}"
url="${db.url}"
userid="${db.user}"
password="${db.pw}"
onerror="continue"
src="db/flush_data.sql">
<classpath refid="master-classpath"/>
</sql>
</target>
<target name="loadData">
<echo message="LOAD DATA USING: ${db.driver} ${db.url}"/>
<sql driver="${db.driver}"
url="${db.url}"
userid="${db.user}"
password="${db.pw}"
onerror="continue"
src="db/load_systems_tables.sql">
<classpath refid="master-classpath"/>
</sql>
</target>
<target name="showTables">
<echo message="SHOW DATABASE TABLES USING: ${db.driver} ${db.url}"/>
<sql driver="${db.driver}"
url="${db.url}"
userid="${db.user}"
password="${db.pw}"
onerror="continue"
print="true">
<classpath refid="master-classpath"/>
SHOW TABLES;
</sql>
</target>
<target name="shutdownDb">
<echo message="SHUT DOWN DATABASE USING: ${db.driver} ${db.url}"/>
<sql driver="${db.driver}"
url="${db.url}"
userid="${db.user}"
password="${db.pw}"
onerror="continue">
<classpath refid="master-classpath"/>
SHUTDOWN;
</sql>
</target>
</project>
tests.failed=${tests.failed}
***********************************************************
***********************************************************
*************测试发现错误*************
***********************************************************
***********************************************************
tests.failed=${tests.failed}
***********************************************************
***********************************************************
*************测试发现错误*************
***********************************************************
***********************************************************
展示表格;
关闭;
您可能应该创建一个执行。甚至还有一种方法可以帮助你做到这一点。或者,您也可以使用jrebel,但它是一种商业产品。您是否在应用程序中启动了任何线程,使其无法正确取消部署?您是否持有任何其他可能被锁定且新应用程序无法访问的资源?你如何重新部署?通过WAR文件或普通目录更改?如果您正在更改目录,那么可能是在tomcat已经部署的情况下仍在更改文件,因此它无法完全部署。您在日志中看到了什么吗?没有使用线程,应用程序也没有保存资源,因为它的注册表单很简单。我正在使用war文件进行部署。但是,当我从ant取消部署时,war文件不会被删除,我必须停止服务并手动删除它,然后运行ant deploy ad restart。可以将热交换配置为也替换war文件吗?我在一个示例中看到,它替换了类文件。我想用它来代替整个战争文件我不这么认为。替换war文件实际上是一种重新部署。至于404错误,这是不正常的-你需要提供更多的信息来帮助理解为什么会发生这种情况。一旦我对应用程序进行了更改,我所做的就是清理、构建、部署和部署。当这种情况发生时,我必须重新启动服务器并运行这些任务,然后重新启动服务器,我将看到除404错误以外的其他更改。如前所述,重新部署新编译的war不是我建议的技术。如果您只更改了代码中的几行,并且没有对API进行任何更改,那么只需热交换该类,它就可以工作,而无需重新启动。这个ant项目是关于使用ant进行热交换的,但与重新部署无关。