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 "> &L T;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> <!
--You can customize the SQL file to perform <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> </t Arget> <target name= "Deploy" depends= "war" > <copy todir= "${env. Catalina_home}/webapps "> <fileset dir=" ${build.war} "includes=" ${web.name}.war "></fileset> </ Copy> </target> </project>