spring web 的ant 文档--备忘

先是build.properties
java 代码
 
  1. # Ant properties for building the springapp  
  2.   
  3. appserver.home=D:/tools/Tomcat 5.0  
  4. deploy.path=${appserver.home}/webapps  
  5.   
  6. tomcat.manager.url=http://localhost:8080/manager  
  7. tomcat.manager.username=admin  
  8. tomcat.manager.password=  
  9. #db properties  
  10. db.driver=com.mysql.jdbc.Driver  
  11. db.url=jdbc:mysql://localhost:3306/test  
  12. db.user=root  
  13. db.pw=1234  

然后是build.xml
xml 代码
 
  1. xml version="1.0" encoding="utf-8"?>  
  2.     <project name="springapp" basedir="." default="usage">  
  3.       <property file="build.properties"/>  
  4.       <property name="src.dir" value="src"/>  
  5.       <property name="web.dir" value="war"/>  
  6.       <property name="build.dir" value="${web.dir}/WEB-INF/classes"/>  
  7.       <property name="name" value="springapp"/>  
  8.       <path id="master-classpath">  
  9.         <fileset dir="${web.dir}/WEB-INF/lib">  
  10.           <include name="*.jar"/>  
  11.         fileset>  
  12.           
  13.           
  14.           
  15.           
  16.         <fileset dir="${appserver.home}/common/lib">  
  17.           <include name="servlet*.jar"/>  
  18.         fileset>  
  19.         <pathelement path="${build.dir}"/>  
  20.       path>  
  21.       <target name="usage">  
  22.         <echo message=""/>  
  23.         <echo message="${name} build file"/>  
  24.         <echo message="-----------------------------------"/>  
  25.         <echo message=""/>  
  26.         <echo message="Available targets are:"/>  
  27.         <echo message=""/>  
  28.         <echo message="build     --> Build the application"/>  
  29.         <echo message="deploy    --> Deploy application as directory"/>  
  30.         <echo message="deploywar --> Deploy application as a WAR file"/>  
  31.         <echo message="install   --> Install application in Tomcat"/>  
  32.         <echo message="reload    --> Reload application in Tomcat"/>  
  33.         <echo message="start     --> Start Tomcat application"/>  
  34.         <echo message="undeploy  --> undeploy Tomcat application"/>  
  35.         <echo message="clean     --> clean classes "/>  
  36.         <echo message="stop      --> Stop Tomcat application"/>  
  37.         <echo message="junit     --> junit the applications"/>  
  38.         <echo message="list      --> List Tomcat applications"/>  
  39.         <echo message=""/>  
  40.       target>  
  41.       <target name="build" description="Compile main source tree java files">  
  42.         <mkdir dir="${build.dir}"/>  
  43.         <javac destdir="${build.dir}"  debug="true"   deprecation="false" optimize="false" failonerror="true">  
  44.           <src path="${src.dir}"/>  
  45.           <classpath refid="master-classpath"/>  
  46.         javac>  
  47.       target>  
  48.       <target name="deploy" depends="build" description="Deploy application">  
  49.         <copy todir="${deploy.path}/${name}" preservelastmodified="true">  
  50.           <fileset dir="${web.dir}">  
  51.             <include name="**/*.*"/>  
  52.           fileset>  
  53.         copy>  
  54.       target>  
  55.       <target name="deploywar" depends="build" description="Deploy application as a WAR file">  
  56.         <war destfile="${name}.war" webxml="${web.dir}/WEB-INF/web.xml">  
  57.           <fileset dir="${web.dir}">  
  58.             <include name="**/*.*"/>  
  59.           fileset>  
  60.         war>  
  61.         <copy todir="${deploy.path}" preservelastmodified="true">  
  62.           <fileset dir=".">  
  63.             <include name="*.war"/>  
  64.           fileset>  
  65.         copy>  
  66.       target>  
  67.         
  68.        <target name="clean" description="Clean output directories">  
  69.         <delete>  
  70.             <fileset dir="${build.dir}">  
  71.                 <include name="**/*.class"/>  
  72.             fileset>  
  73.         delete>  
  74.     target>  
  75.   
  76.     <target name="undeploy" description="Un-Deploy application">  
  77.         <delete>  
  78.             <fileset dir="${deploy.path}/${name}">  
  79.                 <include name="**/*.*"/>  
  80.             fileset>  
  81.         delete>  
  82.     target>  
  83.         
  84.       <target name="junit" depends="build,clearData,loadData" description="Run JUnit Tests">  
  85.         <junit printsummary="on"  
  86.                fork="false"  
  87.                haltonfailure="false"  
  88.                failureproperty="tests.failed"  
  89.                showoutput="true">  
  90.             <classpath refid="master-classpath"/>  
  91.             <formatter type="brief" usefile="false"/>  
  92.   
  93.             <batchtest>  
  94.                 <fileset dir="${build.dir}">  
  95.                     <include name="**/Test*.*"/>  
  96.                 fileset>  
  97.             batchtest>  
  98.   
  99.         junit>  
  100.   
  101.         <fail if="tests.failed">  
  102.                 tests.failed=${tests.failed}  
  103.         ***********************************************************               
  104.         ***********************************************************  
  105.         ****  One or more tests failed!  Check the output ...  ****  
  106.         ***********************************************************  
  107.         ***********************************************************  
  108.         fail>  
  109.     target>  
  110.         
  111.         
  112.     <target name="createTables">  
  113.         <echo message="CREATE TABLES USING: ${db.driver} ${db.url}"/>  
  114.         <sql driver="${db.driver}"  
  115.              url="${db.url}"  
  116.              userid="${db.user}"  
  117.              password="${db.pw}"  
  118.              onerror="continue">    
  119.             <classpath refid="master-classpath"/>  
  120.   
  121.         CREATE TABLE products (  
  122.           id INTEGER NOT NULL PRIMARY KEY,  
  123.           description varchar(255),  
  124.           price decimal(15,2)  
  125.         );  
  126.         CREATE INDEX products_description ON products(description);  
  127.   
  128.         sql>   
  129.     target>  
  130.   
  131.     <target name="dropTables">  
  132.         <echo message="DROP TABLES USING: ${db.driver} ${db.url}"/>  
  133.         <sql driver="${db.driver}"  
  134.              url="${db.url}"  
  135.              userid="${db.user}"  
  136.              password="${db.pw}"  
  137.              onerror="continue">    
  138.             <classpath refid="master-classpath"/>  
  139.   
  140.         DROP TABLE products;  
  141.   
  142.         sql>   
  143.     target>  
  144.   
  145.     <target name="loadData">  
  146.         <echo message="LOAD DATA USING: ${db.driver} ${db.url}"/>  
  147.         <sql driver="${db.driver}"  
  148.              url="${db.url}"  
  149.              userid="${db.user}"  
  150.              password="${db.pw}"  
  151.              onerror="continue">    
  152.             <classpath refid="master-classpath"/>  
  153.   
  154.         INSERT INTO products (id, description, price) values(1, 'Lamp', 5.78);  
  155.         INSERT INTO products (id, description, price) values(2, 'Table', 75.29);  
  156.         INSERT INTO products (id, description, price) values(3, 'Chair', 22.81);  
  157.         COMMIT;  
  158.         sql>   
  159.     target>  
  160.   
  161.     <target name="printData">  
  162.         <echo message="PRINT DATA USING: ${db.driver} ${db.url}"/>  
  163.         <sql driver="${db.driver}"  
  164.              url="${db.url}"  
  165.              userid="${db.user}"  
  166.              password="${db.pw}"  
  167.              onerror="continue"  
  168.              print="true">    
  169.             <classpath refid="master-classpath"/>  
  170.   
  171.         SELECT * FROM products;  
  172.   
  173.         sql>   
  174.     target>  
  175.   
  176.     <target name="clearData">  
  177.         <echo message="CLEAR DATA USING: ${db.driver} ${db.url}"/>  
  178.         <sql driver="${db.driver}"  
  179.              url="${db.url}"  
  180.              userid="${db.user}"  
  181.              password="${db.pw}"  
  182.              onerror="continue">    
  183.             <classpath refid="master-classpath"/>  
  184.   
  185.         DELETE FROM products;  
  186.   
  187.         sql>   
  188.     target>  
  189.    
  190.   
  191.         
  192.         
  193.         
  194.         
  195.       <taskdef name="install" classname="org.apache.catalina.ant.InstallTask">  
  196.         <classpath>  
  197.           <path location="${appserver.home}/server/lib/catalina-ant.jar"/>  
  198.         classpath>  
  199.       taskdef>  
  200.       <taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask">  
  201.         <classpath>  
  202.           <path location="${appserver.home}/server/lib/catalina-ant.jar"/>  
  203.         classpath>  
  204.       taskdef>  
  205.       <taskdef name="list" classname="org.apache.catalina.ant.ListTask">  
  206.         <classpath>  
  207.           <path location="${appserver.home}/server/lib/catalina-ant.jar"/>  
  208.         classpath>  
  209.       taskdef>  
  210.       <taskdef name="start" classname="org.apache.catalina.ant.StartTask">  
  211.         <classpath>  
  212.           <path location="${appserver.home}/server/lib/catalina-ant.jar"/>  
  213.         classpath>  
  214.       taskdef>  
  215.       <taskdef name="stop" classname="org.apache.catalina.ant.StopTask">  
  216.         <classpath>  
  217.           <path location="${appserver.home}/server/lib/catalina-ant.jar"/>  
  218.         classpath>  
  219.       taskdef>  
  220.       <target name="install" description="Install application in Tomcat">  
  221.         <install url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${name}" war="${name}"/>  
  222.       target>  
  223.       <target name="reload" description="Reload application in Tomcat">  
  224.         <reload url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${name}"/>  
  225.       target>  
  226.       <target name="start" description="Start Tomcat application">  
  227.         <start url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${name}"/>  
  228.       targ
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值