Summary of MiddleGen

xiaoxiao2021-03-05  20

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. 3) Modify Build.xml to modify the build.xml file under the MiddleGen root, this file is MiddleGen-Hibernate's ANT build configuration. MiddleGen-Hibernate generates a database table mapping file according to the specific parameters in the build.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: "avine" is the default Application Name in the MiddleGen original configuration, modify it to our desired name, such as "HibernateSample" : c) Output Directory Find Keyword "Name =" Build.gen-src.dir ", get: Modify value =" $ {build.dir} / gen-src "to point to the output directory we expect, here we have modified: d) Package Name of the corresponding code Find the keyword "destination", get: can be seen, the default setting is actually hibernate package attribute node is preceded by The application name ($ {name}) and ".hibernate" are successful, according to our needs, it will be changed to: < hibernatedestination = "$ {build.gen-src.dir}" package = "org.hibernate.sample" genXDocletTags = "true" genIntergratedCompositeKeys = "false" javaTypeMapper = "middlegen.plugins.hibernate.HibernateJavaTypeMapper" /> where there is a Property GenxDoclettags, if set to true,

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:

转载请注明原文地址:https://www.9cbs.com/read-37882.html

New Post(0)