TOMCAT和ANT都是APACHE的开源项目。TOMCAT自带了ANT作为JSP编译器及TOMCAT管理工具。
TOMCAT自带的管理界面:
admin和manager分别负责TOMCAT的配置和管理。这里主要使用manager对TOMCAT下的单个WEB应用进行重启等操作
1、首先设置用户
E:\Tomcat 5.0\conf\tomcat-users.xml
<user username="manager" password="1234" roles="manager"/>
<user username="admin" password="1234" roles="admin,manager"/>
2、正常地登录本机管理界面看是否能正常使用
3、需要找到TOMCAT目录中ant拓展的JAR包 ,此包负责一些和TOMCAT有关的TARGET拓展
catalina-ant.jar
4、build.xml & build.properties
<!-- The build.xml -->
<project name="test" default="about" basedir=".">
<description>
The build.xml of this project, used by ant. Do NOT modify this file unless mastering ant.
</description>
<property file="build.properties" />
<taskdef name="start" classname="org.apache.catalina.ant.StartTask">
</taskdef>
<taskdef name="stop" classname="org.apache.catalina.ant.StopTask">
</taskdef>
<target name="reload" description="Reload application in Tomcat">
<reload
url="${tomcat.manager.url}" username="${tomcat.manager.username}"
password="${tomcat.manager.password}" path="/${webapp.name}" />
</target>
<target name="start" description="Start Tomcat application">
<start
url="${tomcat.manager.url}" username="${tomcat.manager.username}"
password="${tomcat.manager.password}" path="/${webapp.name}" />
</target>
<target name="stop" description="Stop Tomcat application">
<stop
url="${tomcat.manager.url}" username="${tomcat.manager.username}"
password="${tomcat.manager.password}" path="/${webapp.name}" />
</target>
<target name="about" depends="" description="">
<description>
The build.xml of this project, used by ant. Do NOT modify this file unless mastering ant.
</description>
</target>
</project>
webapp.name=caseanalysis
tomcat.home=E:/Tomcat 5.0
tomcat.manager.url=http://localhost/manager
tomcat.manager.username=manager
tomcat.manager.password=1234
视情况需要在taskdef中加入classpath
<classpath>
<path location="${appserver.home}/server/lib/catalina-ant.jar" />
</classpath>
注:java.io.IOException 401错误什么的,是用户名密码错