Ant之启动和停止tomcat
一般在大型的软件编译,打包,部署都离不开ant,例如我们在执行 ant deploy的command的时候不仅仅要打包成war包,还需要启动tomcat,启动包括直接start,以及debug模式启动,和stop tomcat.
<!-- Launches Tomcat --><target name="tomcat-start" description="Launches Tomcat"><fail unless="env.TOMCAT_HOME"message="You must set the TOMCAT_HOME environment variable to point to your Tomcat installation folder"/><exec dir="${env.TOMCAT_HOME}/bin" executable="catalina.bat"vmlauncher="false" spawn="true"><arg value="start"/></exec></target><!-- Launches Tomcat in debug mode --><target name="tomcat-start-debug" description="Launches Tomcat in JDPA debug mode on port 8000"><fail unless="env.TOMCAT_HOME"message="You must set the TOMCAT_HOME environment variable to point to your Tomcat installation folder"/><exec dir="${env.TOMCAT_HOME}/bin" executable="catalina.bat"vmlauncher="false" spawn="true"><arg value="jpda"/><arg value="start"/><env key="JPDA_ADDRESS" value="8000"/><env key="JPDA_TRANSPORT" value="dt_socket"/></exec></target><!-- Shuts down Tomcat --><target name="tomcat-stop" description="Shuts down Tomcat"><fail unless="env.TOMCAT_HOME"message="You must set the TOMCAT_HOME environment variable to point to your Tomcat installation folder"/><exec dir="${env.TOMCAT_HOME}/bin" executable="shutdown.bat"vmlauncher="false" spawn="true"/><sleep seconds="2"/></target>
dt_socket:表示使用远程调式(dt_shmem表示本地调式),采用类似注入变量的形式去设置一些启动属性,避免手动修改catalina.bat文件。