Ant步步为营(4)ant启动tomcat
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了Ant步步为营(4)ant启动tomcat,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2675字,纯文字阅读大概需要4分钟。
内容图文
![Ant步步为营(4)ant启动tomcat](/upload/InfoBanner/zyjiaocheng/1050/eecafbdb00644e7eabf050892b9ae893.jpg)
前序:
最近产品要release,一直忙着测试,没有时间学习ant了,今天终于没什么事了赶紧写点东西。这个启动tomcat是好些天之前写的了。在这里跟大家分享一下。
build.xml
<?xml version="1.0"?>
<project name="ForTest"
default="start_tomcat" >
<property
file="build.properties"></property>
<target name="stop_tomcat">
<echo>停止tomcat</echo>
<exec executable="cmd"
dir="${tomcat.home}/bin" failonerror="false"
output="${log.file}" append="true" >
<!-- <arg value="/c" /> -->
<env key="CATALINA_HOME" path="${tomcat.home}"/>
<arg
value="/c"/>
<arg value="shutdown.bat"/>
</exec>
</target>
<target name="start_tomcat" depends="stop_tomcat">
<echo>启动tomcat</echo>
<exec executable="cmd"
dir="${tomcat.home}/bin" failonerror="false"
output="${log.file}" append="true" >
<!-- <arg value="/c" /> -->
<env key="CATALINA_HOME" path="${tomcat.home}"/>
<arg value="/c startup.bat" />
</exec>
</target>
</project>
build.properties
tomcat.home=G:\\apache-tomcat-7.0.42-windows-x64\\apache-tomcat-7.0.42
注意几点:
exec executable="cmd"这一句是用在window系统下用cmd的方式启动tomcat。
<env key="CATALINA_HOME" path="${tomcat.home}"/>必须指明CATALINA_HOME的值。
env是ant的数据类型,参考:http://www.cnblogs.com/xionghui/archive/2012/03/13/2393679.html
/c的解释:(参考ant api)
Windows Users
The <exec>
task
delegates to Runtime.exec
which in turn apparently calls ::CreateProcess. It is the latter Win32 function that defines
the exact semantics of the call. In particular, if you do not put a file
extension on the executable, only ".EXE" files are looked for, not ".COM",
".CMD" or other file types listed in the environment variable PATHEXT. That is
only used by the shell.
Note that .bat files cannot in general by
executed directly. One normally needs to execute the command shell executable
cmd
using the /c
switch.
<target name="help">
<exec executable="cmd">
<arg value="/c"/>
<arg value="ant.bat"/>
<arg value="-p"/>
</exec>
</target>
A common problem is not having the executable on the PATH. In case you get an error message Cannot run program "...":CreateProcess error=2. The system cannot find the path specified. have a look at your PATH variable. Just type the command directly on the command line and if Windows finds it, Ant should do it too. (Otherwise ask on the user mailinglist for help.) If Windows can not execute the program add the directory of the program to the PATH (set PATH=%PATH%;dirOfProgram) or specify the absolute path in the executable attribute in your buildfile.
原文:http://www.cnblogs.com/QAZLIU/p/3732273.html
内容总结
以上是互联网集市为您收集整理的Ant步步为营(4)ant启动tomcat全部内容,希望文章能够帮你解决Ant步步为营(4)ant启动tomcat所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。