在项目的根目录下我创建了build.xml文件,内容如下:
<?xml version="1.0" encoding="utf-8"?>
<project name="hibernate" default="schema" basedir=".">
<!--定义一些属性-->
<!--<property name="dir.lib" value="/Users/liaowenxiong/.m2/repository"/>-->
<property name="dir.lib" value="/Users/liaowenxiong/.m2/repository"/>
<property name="dir.src" value="/Users/liaowenxiong/Documents/IdeaProjects/hibernate-basic/src/main/java"/>
<property name="dir.classes" value="/Users/liaowenxiong/Documents/IdeaProjects/hibernate-basic/target/classes
"/>
<!--定义Build路径-->
<path id="cp">
<!--定义一組文件-->
<fileset dir="${dir.lib}">
<include name="**/*.jar"/>
</fileset>
<!--定义一个目录-->
<pathelement path="${dir.classes}"/>
</path>
<target name="t1">
<!--ANT Task 1-->
<copy todir="note">
<fileset dir="src/main/resources">
<include name="**/*.properties"/>
</fileset>
</copy>
</target>
<target name="t2">
<!--ANT Task 2-->
<delete dir="note"/>
<mkdir dir="note"/>
<native2ascii encoding="gbk" src="src/main/resources" dest="note" includes="**/*.txt"/>
<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="cp"/>
</target>
<target name="schema">
<hibernatetool destdir=".">
<classpath refid="cp"/>
<configuration configurationfile="${dir.classes}/hibernate.cfg.xml"/>
<hbm2ddl
drop="true"
create="true"
console="true"
export="true"
outputfilename="schema.sql"
delimiter=";"
format="true"/>
</hibernatetool>
</target>
</project>
但是标签<taskdef>和<hibernatetool>报错,无法识别。为什么?