下载http://www.apache.org/dist/ant/binaries下的apache-ant-1.6.1-bin.zip 解压缩安装。
ant的配法: 1。解压ant的包到本地目录。
2。在环境变量中设置ANT_HOME,值为你的安装目录。
3。在环境变量中设置JAVA_HOME,值为你的jdk安装目录。
4。把ANT_HOME/bin加到你系统的path目录中去。 SET ANT_HOME=D:/jakarta-ant-1.5.1 //注意是Ant的安装目录,不是bin子目录 SET PATH=%PATH%;%ANT_HOME%/bin; 在cmd模式下输入 ant -version回车,看到输出说明配置成功。
自己摸索的,网上写的不是太全,一定要注意ant_home和path中的本地目录,一般来说,path的目录是{dir}/bin,而ant_home的则是path的上级目录。我摸索了几次,最后则把apache-ant-1.6.5-bin(解压缩的原目录)给删除了,因为里面有个bin关键字,重新设置ant_home和path,在cmd下ant ,ok,虽然报错:没有找到build.xml文件,这也是成功了,
然后我做的事是用MiddleGen 生成hbm.xml文件,在cmd下进入MiddleGen下的bin目录(里面有个build.xml已提前配置好了,),出现一些说明,如那个表没有主键等,稍后一会,运行出来一个java的applet的界面,可以看到你的scheml下的所有表及其主键和关联,点击generat,即在你的配置文件声明的目录下生产了许多的hbm.xml文件。我用文件比较软件,看了一下,这些生成的文件和用myeclipse中的myeclipse data expiorer视图下的generate hibernate xml文件,大体上是相同的,也有一些显著的不同,具体的就不说了了,还是大家自己试一下吧。
完整的命令运行过程如下 C:/Middlegen-Hibernate-r5/Middlegen-Hibernate-r5>antBuildfile: build.xmlWarning: 'file:./config/database/oracle.xml' in C:/Middlegen-Hibernate-r5/Middlegen-Hibernate-r5/build.xml should be expressed simply as './config/database/oracle.xml' for compliance with other XML tools init: fail-if-no-xdoclet-1.2: check-driver-present: panic-if-driver-not-present: middlegen: [echo] Class path = C:/Middlegen-Hibernate-r5/Middlegen-Hibernate-r5[middlegen] Database URL:jdbc:oracle:thin:@192.168.11.85:1521:orcl[middlegen] No <table> elements specified. Reading all tables. This might take a while...[middlegen] (middlegen.MiddlegenPopulator 1020) WARNING: The JDBC driverdidn't report any primary key columns in FC_INVOICE[middlegen] (middlegen.MiddlegenPopulator 1020) WARNING: The JDBC driverdidn't report any primary key columns in FC_DV_INTERFACE1[middlegen] (middlegen.MiddlegenPopulator 1020) WARNING: The JDBC driverdidn't report any primary key columns in FC_CODES[middlegen] (middlegen.MiddlegenPopulator 1020) WARNING: The JDBC driverdidn't report any primary key columns in FC_INVOICEDETAIL[middlegen] (middlegen.MiddlegenPopulator 1020) WARNING: The JDBC driverdidn't report any primary key columns in FC_INVOICE_DETAIL[middlegen] (middlegen.MiddlegenPopulator 1020) WARNING: The JDBC driverdidn't report any primary key columns in FC_ALLDETAIL[middlegen] (middlegen.MiddlegenPopulator 1020) WARNING: The JDBC driverdidn't report any primary key columns in FC_ALLCLASS[middlegen] (middlegen.MiddlegenPopulator 1020) WARNING: The JDBC driverdidn't report any primary key columns in RE_LOG[middlegen] (middlegen.MiddlegenPopulator 1020) WARNING: The JDBC driverdidn't report any primary key columns in FC_INVOICEBACK[middlegen] (middlegen.MiddlegenPopulator 1020) WARNING: The JDBC driverdidn't report any primary key columns in FC_ALLMATERIAL[middlegen] (middlegen.MiddlegenPopulator 1020) WARNING: The JDBC driverdidn't report any primary key columns in FC_INVOICE_MANAGE_370700[middlegen] ********************************************************[middlegen] * CTRL-Click relations to modify their cardinality *[middlegen] * SHIFT-Click relations to modify their directionality *[middlegen] ********************************************************[middlegen] Updated preferences in C:/Middlegen-Hibernate-r5/Middlegen-Hibernate-r5/src/feehibernate-prefs.properties compile-hibernate: all: BUILD SUCCESSFULTotal time: 4 minutes 29 seconds