When using Hibernate, too many Hibernate configuration files are a headache. Recently, I have been familiar with the Xdoclet tool. It is actually an automatic code generation tool. Xdoclet cannot be run independently and must be used together with other tools, such as ant. If the ant tool is not used, we recommend that you first add the basic knowledge of ant to learn Xdoclet. First, ensure that the ant on the machine is available. 2. Download Xdoclet and decompress it. 3. Define the xdoclet task in ant build. xml. Here we will generate the hibernate ing File Based on the hibernate object class, so we must first have the Hibernate object class. [Java]/*** @ hibernate. class * table = "T_Party" */public class Party {/*** @ hibernate. id * generator-class = "native" */private int id;/*** @ hibernate. welcome-to-one * column = "parentid" */private Party parent;/*** @ hibernate. set * @ hibernate. key * column = "parentid" * @ hibernate. one-to-operate * class = "com. bjsxt. oa. model. party "*/private Set children;/*** @ hibernate. property * column = "thenam E "*/private String name;/*** @ hibernate. property */private String sn;/*** @ hibernate. property */private String description;/***** @ return */public Set getChildren () {return children;} public void setChildren (Set children) {this. children = children;} public String getDescription () {return description;} public void setDescription (String description) {this. description = description; }/***/Public int getId () {return id;} public void setId (int id) {this. id = id;} public String getName () {return name;} public void setName (String name) {this. name = name;} public Party getParent () {return parent;} public void setParent (Party parent) {this. parent = parent;} public String getSn () {return sn;} public void setSn (String sn) {this. sn = sn ;}} after adding the corresponding annotation to the object class, define a new. [Java] <? Xml version = "1.0" encoding = "GBK"?> <Project name = "system build script" default = "generate Hibernate configuration file" basedir = ". "> <property name =" src. dir "value =" $ {basedir}/src "/> <property name =" build. dir "value =" $ {basedir}/bin "/> <property name =" webapp. dir "value =" $ {basedir}/src/webapp "/> <property name =" xdoclet. home "value =" E: xdoclet-plugins-1.0.3 "/> <! -- Build classpath --> <path id = "xdoclet. task. classpath "> <fileset dir =" $ {xdoclet. home}/lib "> <include name = "**/*. jar "/> </fileset> <fileset dir =" $ {xdoclet. home}/plugins "> <include name = "**/*. jar "/> </fileset> </path> <taskdef name =" xdoclet "classname =" org. xdoclet. ant. XDocletTask "classpathref =" xdoclet. task. classpath "/> <target name =" generate Hibernate configuration file "> <xdoclet> <fileset dir =" $ {src. dir}/com/bjsxt/o A/model "> <include name = "**/*. java "/> </fileset> <component classname =" org. xdoclet. plugin. hibernate. hibernateConfigPlugin "destdir =" $ {src. dir} "version =" 3.0 "hbm2ddlauto =" update "jdbcurl =" jdbc: mysql: // 127.0.0.1/oa "jdbcdriver =" com. mysql. jdbc. driver "jdbcusername =" root "jdbcpassword =" mysql "dialect =" org. hibernate. dialect. mySQLDialect "showsql =" true "/> </xdoclet> </target> <target name =" generate hibernate Ing file "> <xdoclet> www.2cto.com <fileset dir =" $ {src. dir}/com/bjsxt/oa/model "> <include name = "**/*. java "/> </fileset> <component classname =" org. xdoclet. plugin. hibernate. hibernateMappingPlugin "version =" 3.0 "destdir =" $ {src. dir} "/> </xdoclet> </target> </project> you can see that two tasks are defined in ant, that is, the hibernate ing file and the hibernate configuration file are generated. After the configuration is complete, run the command to generate the corresponding configuration file.