使用 ant 让你愉快编程(5)

摘要: build_tomcat.xml, tomcat.xml

现在介绍一下如何与 tomcat 一起配合工作.
java 的程序很大部分都涉及 web, 自己测试时使用 tomcat 还是很方便的,
所以有必要介绍一下.

在 work/common/ 下的 build_tomcat.xml, tomcat.xml 这两个文件是与
tomcat 配合工作的配置文件, 它的内容很简单.

. 以下为 build_tomcat.xml 文件内容:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
    Copyright 2004 camry.wu@gmail.com

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc..
-->
<project name="tomcat target file" default="start" basedir="">

  <description>
      与tomcat相互配合的任务. Version 1.0.
      Copyright 2004 camry.wu@gmail.com
  </description>

  <!-- 读入 tomcat 配置 -->
  <xmlproperty  file="${path.common}/tomcat.xml"
                semanticAttributes="true" keepRoot="false"/>

  <!-- 发布到 tomcat -->
  <target name="deploy_tomcat"
          depends="compile" description="Deploy application">
    <copy todir="${path.war}/WEB-INF/classes" preservelastmodified="true">
      <fileset dir="${dist}/classes">
        <include name="**/*"/>
      </fileset>
    </copy>
    <copy todir="${path.war}/WEB-INF/lib" preservelastmodified="true">
      <fileset dir="${dist}/lib">
        <include name="**/*"/>
      </fileset>
    </copy>
    <copy todir="${path.deploy}/${component.name}" preservelastmodified="true">
      <fileset dir="${path.war}">
        <include name="**/*"/>
      </fileset>
    </copy>
  </target>

  <!-- 撤销发布 -->
  <target name="undeploy_tomcat" description="Un-Deploy application">
    <delete>
      <fileset dir="${tomcat.home}/webapps/${component.name}">
        <include name="**/*"/>
      </fileset>
    </delete>
  </target>

  <!-- 发布为 war 形式 -->
  <target name="deploywar"
          depends="jar" description="Deploy application as a WAR file">
    <war destfile="${component.name}.war" webxml="${path.war}/WEB-INF/web.xml">
      <fileset dir="${path.war}">
        <include name="**/*"/>
      </fileset>
    </war>
    <copy todir="${path.deploy}" preservelastmodified="true">
      <fileset dir=".">
        <include name="*.war"/>
      </fileset>
    </copy>
  </target>

  <!-- install 工程 -->
  <taskdef name="install" classname="org.apache.catalina.ant.InstallTask">
    <classpath>
      <path location="${tomcat.home}/server/lib/catalina-ant.jar"/>
    </classpath>
  </taskdef>

  <!-- reload 工程 -->
  <taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask">
    <classpath>
      <path location="${tomcat.home}/server/lib/catalina-ant.jar"/>
    </classpath>
  </taskdef>

  <!-- 查看工程列表 -->
  <taskdef name="list" classname="org.apache.catalina.ant.ListTask">
    <classpath>
      <path location="${tomcat.home}/server/lib/catalina-ant.jar"/>
    </classpath>
  </taskdef>

  <!-- 启动 tomcat -->
  <taskdef name="start" classname="org.apache.catalina.ant.StartTask">
    <classpath>
      <path location="${tomcat.home}/server/lib/catalina-ant.jar"/>
    </classpath>
  </taskdef>

  <!-- 停止 tomcat -->
  <taskdef name="stop" classname="org.apache.catalina.ant.StopTask">
    <classpath>
      <path location="${tomcat.home}/server/lib/catalina-ant.jar"/>
    </classpath>
  </taskdef>

  <!-- install 工程 -->
  <target name="install" description="Install application in Tomcat">
    <install  url="${tomcat.manager.url}"
              username="${tomcat.manager.username}"
              password="${tomcat.manager.password}"
              path="/${component.name}"
              war="${component.name}.war"/>
  </target>

  <!-- reload 工程 -->
  <target name="reload" description="Reload application in Tomcat">
    <reload url="${tomcat.manager.url}"
            username="${tomcat.manager.username}"
            password="${tomcat.manager.password}"
            path="/${component.name}"/>
  </target>

  <!-- 启动 tomcat -->
  <target name="start" description="Start Tomcat application">
    <start  url="${tomcat.manager.url}"
            username="${tomcat.manager.username}"
            password="${tomcat.manager.password}"
            path="/${component.name}"/>
  </target>

  <!-- 停止 tomcat -->
  <target name="stop" description="Stop Tomcat application">
    <stop url="${tomcat.manager.url}"
          username="${tomcat.manager.username}"
          password="${tomcat.manager.password}"
          path="/${component.name}"/>
  </target>

  <!-- 查看工程列表 -->
  <target name="list" description="List Tomcat applications">
    <list url="${tomcat.manager.url}"
          username="${tomcat.manager.username}"
          password="${tomcat.manager.password}"/>
  </target>
</project>


以下为 tomcat.xml 的内容.

<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
    Copyright 2004 camry.wu@gmail.com
    Ant build environment for tomcat
-->

<root>
  <tomcat>
    <!-- 配置 tomcat.home 位置 -->
    <home value="/usr/tomcat.home"/>
    <!-- 配置 tomcat 的管理界面 -->
    <manager>
      <url>http://127.0.0.1:8080/manager</url>
      <username>camry</username>
      <password>xxxxx</password>
    </manager>
  </tomcat>

  <path>
    <!-- 配置发布的源 war 位置 -->
    <war>war</war>
    <!-- 发布到 tomcat 的 webapps 目录下 -->
    <deploy>${tomcat.home}/webapps</deploy>
  </path>
</root>


在使用的时候, 要注意先在 work/工程目录/ 下建立 war 目录,
war 目录结构为:
  work/工程目录/war
      WEB-INF/
        classes/                  # 放置 class 文件
        lib/                      # 放置需要的 jar 包
        web.xml                   # web 配置文件

有了这些配置, 在与 tomcat 配合时只要启动 tomcat 先, 随后就不用
再管 tomcat 了, 只要调用 ant deploy, ant stop, ant start 等等
任务就可以了.
智慧旅游解决方案利用云计算、物联网和移动互联网技术,通过便携终端设备,实现对旅游资源、经济、活动和旅游者信息的智能感知和发布。这种技术的应用旨在提升游客在旅游各个环节的体验,使他们能够轻松获取信息、规划行程、预订票务和安排食宿。智慧旅游平台为旅游管理部门、企业和游客提供服务,包括政策发布、行政管理、景区安全、游客流量统计分析、投诉反馈等。此外,平台还提供广告促销、库存信息、景点介绍、电子门票、社交互动等功能。 智慧旅游的建设规划得到了国家政策的支持,如《国家中长期科技发展规划纲要》和国务院的《关于加快发展旅游业的意见》,这些政策强调了旅游信息服务平台的建设和信息化服务的重要性。随着技术的成熟和政策环境的优化,智慧旅游的时机已经到来。 智慧旅游平台采用SaaS、PaaS和IaaS等云服务模式,提供简化的软件开发、测试和部署环境,实现资源的按需配置和快速部署。这些服务模式支持旅游企业、消费者和管理部门开发高性能、高可扩展的应用服务。平台还整合了旅游信息资源,提供了丰富的旅游产品创意平台和统一的旅游综合信息库。 智慧旅游融合应用面向游客和景区景点主管机构,提供无线城市门户、智能导游、智能门票及优惠券、景区综合安防、车辆及停车场管理等服务。这些应用通过物联网和云计算技术,实现了旅游服务的智能化、个性化和协同化,提高了旅游服务的自由度和信息共享的动态性。 智慧旅游的发展标志着旅游信息化建设的智能化和应用多样化趋势,多种技术和应用交叉渗透至旅游行业的各个方面,预示着全面的智慧旅游时代已经到来。智慧旅游不仅提升了游客的旅游体验,也为旅游管理和服务提供了高效的技术支持。
智慧旅游解决方案利用云计算、物联网和移动互联网技术,通过便携终端设备,实现对旅游资源、经济、活动和旅游者信息的智能感知和发布。这种技术的应用旨在提升游客在旅游各个环节的体验,使他们能够轻松获取信息、规划行程、预订票务和安排食宿。智慧旅游平台为旅游管理部门、企业和游客提供服务,包括政策发布、行政管理、景区安全、游客流量统计分析、投诉反馈等。此外,平台还提供广告促销、库存信息、景点介绍、电子门票、社交互动等功能。 智慧旅游的建设规划得到了国家政策的支持,如《国家中长期科技发展规划纲要》和国务院的《关于加快发展旅游业的意见》,这些政策强调了旅游信息服务平台的建设和信息化服务的重要性。随着技术的成熟和政策环境的优化,智慧旅游的时机已经到来。 智慧旅游平台采用SaaS、PaaS和IaaS等云服务模式,提供简化的软件开发、测试和部署环境,实现资源的按需配置和快速部署。这些服务模式支持旅游企业、消费者和管理部门开发高性能、高可扩展的应用服务。平台还整合了旅游信息资源,提供了丰富的旅游产品创意平台和统一的旅游综合信息库。 智慧旅游融合应用面向游客和景区景点主管机构,提供无线城市门户、智能导游、智能门票及优惠券、景区综合安防、车辆及停车场管理等服务。这些应用通过物联网和云计算技术,实现了旅游服务的智能化、个性化和协同化,提高了旅游服务的自由度和信息共享的动态性。 智慧旅游的发展标志着旅游信息化建设的智能化和应用多样化趋势,多种技术和应用交叉渗透至旅游行业的各个方面,预示着全面的智慧旅游时代已经到来。智慧旅游不仅提升了游客的旅游体验,也为旅游管理和服务提供了高效的技术支持。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值