简体   繁体   English

使用ANT脚本启动和停止tomcat?

[英]starting and stopping tomcat using ANT script?

I have below ANT script to start/stop tomcat: 我在ANT脚本下面启动/停止tomcat:

   <project name="sample">
<property name="name" value="sample"/>
<path id="catalina-ant-classpath"> 
<fileset dir="D:\apache-tomcat-7.0.47-windows-x64\apache-tomcat-7.0.47\lib"> 
<include name="catalina-ant.jar"/> 
</fileset> 
</path> 
<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="start" description="Start Tomcat application">
<start url="http://localhost:8080/manager"
username="uname"
password="pwd"/>
</target>
<target name="stop" description="Stop Tomcat application">
<stop url="http://localhost:8080/manager"
username="uname"
password="pwd"/>
</target>
</project>

When i run above script it throws below Error: 当我在脚本上面运行它会抛出以下错误:

D:\\apache-ant-1.9.3-bin\\apache-ant-1.9.3\\bin>ant build.xml stop Buildfile: D:\\apache-ant-1.9.3-bin\\apache-ant-1.9.3\\bin\\build.xml BUILD FAILED Target "build.xml" does not exist in the project "sample". D:\\ apache-ant-1.9.3-bin \\ apache-ant-1.9.3 \\ bin> ant build.xml stop Buildfile:D:\\ apache-ant-1.9.3-bin \\ apache-ant-1.9.3 \\ bin \\ build.xml BUILD FAILED项目“sample”中不存在目标“build.xml”。

Is there any wrong in above script? 上面的脚本有什么问题吗?

Thanks! 谢谢!

Your build.xml is missing the root element <project> . 您的build.xml缺少根元素<project> Please see ant documentation. 请参阅ant文档。

Remove the name attribute it is optional. 删除它是可选的name属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM