Environmental configuration needs package: JSDK, Ant, Hibernate, Hibernate-Extension, Middlegen
The two environment variables set the general step to refer to the online, I am using the copy% hibernate_home% / lib * .jar to% middlegen% / lib copy% hibernate_home% / hibernate2.jar to% middlegen% / lib copy% hibernate-extension_home % / Tools / lib * .jar to% middlegen% / lib copy% hibernate-extension_home% / Tools / Hibernate-Tools.jar to% MiddleGen% / LIB
Three MiddleGen configuration Configure the target database parameter into the / config / database subdirectory under the MiddleGen directory, open the corresponding configuration file based on the database we actually use. As we use here is the MySQL database, the corresponding is mysql.xml file.
Configurable items include: a) Target database configuration file address lookup keyword "!" In the case, MiddleGen uses hsqldb.xml, modify it to the database profile we use: ]> b) Application Name Find:
The generated code will contain XDoclet Tag, which provides help from the future by means of xdoclets in the development process, MiddleGen has been configured, running Ant in the MiddleGen root directory, will appear MiddleGen interface:
Four .xml to .java After getting .XML, use ant HBM2JAVA to get the corresponding Java file
Summary: I first run success, but later, there were similar errors, and the inspection found that there were multiple similar JAR packages (velocity.jar, velocity ***. Jar) in MiddleGen's lib directory, after deleting old JAR packages ,problem solved
[Middlegen] java.lang.IncompatibleClassChangeError [middlegen] at middlegen.KindFileResourceLoader.getResourceStream (KindFileResourceLoader.java:82) [middlegen] at org.apache.velocity.Template.process (Template.java:136) [middlegen] at org. apache.velocity.runtime.resource.ResourceManagerImpl.loadResource (ResourceManagerImpl.java:466) [middlegen] at org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource (ResourceManagerImpl.java:384) [middlegen] at org.apache. velocity.runtime.RuntimeInstance.getTemplate (RuntimeInstance.java:814) [middlegen] at org.apache.velocity.runtime.RuntimeInstance.getTemplate (RuntimeInstance.java:796) [middlegen] at org.apache.velocity.runtime.VelocimacroFactory. initVelocimacro (VelocimacroFactory.java:211) [middlegen] at org.apache.velocity.runtime.RuntimeInstance.init (RuntimeInstance.java:276) [middlegen] at org.apache.velocity.runtime.RuntimeInstance.init (RuntimeInstance.java: 441) [Middlegen] at Org.Apache.velocity.app.v elocityEngine.init (VelocityEngine.java:148) [middlegen] at middlegen.Plugin.getEngine (Plugin.java:560) [middlegen] at middlegen.Plugin.generate (Plugin.java:444) [middlegen] at middlegen.Middlegen. writeSource (Middlegen.java:411) [middlegen] at middlegen.swing.JMiddlegenFrame $ 1.actionPerformed (JMiddlegenFrame.java:72) [middlegen] at javax.swing.AbstractButton.fireActionPerformed (AbstractButton.java:1786) [middlegen] at javax .swing.AbstractButton $ ForwardActionEvents.actionPerformed (AbstractButton.java:1839) [middlegen] at javax.swing.DefaultButtonModel.fireActionPerformed (DefaultButtonModel.java:420) [middlegen] at javax.swing.DefaultButtonModel.setPressed (DefaultButtonModel.java: