ant學習筆記(六)ant編譯web項目,並打成war包,同時加入資料庫操作

來源:互聯網
上載者:User


build.xml

<?xml version="1.0" encoding="UTF-8"?><project><property name="src.dir" location="src"></property><property name="build.dir" location="build"></property><property name="build.classes" location="${build.dir}/classes"></property><property name="build.war" location="${build.dir}/war"></property><property name="web.name" value="hello"></property><property name="web.root" value="WebContent"></property><property name="web.WEB-INF" location="${web.root}/WEB-INF"></property><property name="web.lib" location="${web.WEB-INF}/lib"></property><property environment="env"></property><path id="compile"><fileset dir="${web.lib}" includes="*.jar"></fileset><fileset dir="${env.CATALINA_HOME}/lib" includes="*.jar"></fileset></path><target name="init"><delete dir="${build.dir}"></delete><mkdir dir="${build.dir}"/><mkdir dir="${build.classes}"/><mkdir dir="${build.war}"/></target><target name="compile" depends="init"><javac destdir="${build.classes}" srcdir="${src.dir}" classpathref="compile"></javac></target><target name="war" depends="compile"><war destfile="${build.war}/${web.name}.war"><fileset dir="${web.root}" includes="**/*.*"></fileset><lib dir="${web.lib}"></lib><webinf dir="${web.WEB-INF}"></webinf><classes dir="${build.classes}"></classes></war></target><presetdef name="sql-admin"><sql userid="root" password="root" url="jdbc:mysql://localhost:3306/hibernate?useUnicode=true&characterEncoding=utf-8" driver="com.mysql.jdbc.Driver"><classpath refid="compile"></classpath></sql></presetdef><target name="init-mysql"><sql-admin><!-- 可以自訂sql檔案來執行<transaction src="sql.sql">--><transaction>drop database ant_test;create database ant_test;GRANT ALL ON ant_test.* TO "ant_test"@"localhost" IDENTIFIED BY '123'</transaction></sql-admin></target><target name="deploy" depends="war"><copy todir="${env.CATALINA_HOME}/webapps"><fileset dir="${build.war}" includes="${web.name}.war"></fileset></copy></target></project>


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.