To get up and running quickly with MyBatis Generator (MBG), follow these steps:
<jdbcConnection>
element to specify how to connect to
the target database<javaModelGenerator>
element to specify target package
and target project for generated Java model objects<sqlMapGenerator>
element to specify target package
and target project for generated SQL map files<javaClientGenerator>
element to specify target package
and target project for generated client interfaces and classes (you may
omit the <javaClientGenerator>
element if you don't wish to generate Java client code)<table>
elementSee the XML Configuration File Reference page for an example of a configuration file.
java -jar mybatis-generator-core-x.x.x.jar -configfile \temp\generatorConfig.xml -overwrite
This will tell MBG to run using your configuration file. It will also tell MBG
to overwrite any existing Java files with the same name. If you want to save any existing
Java files, then omit the -overwrite
parameter. If there is a conflict, MBG
will save the newly generated file with a unique name (e.g. MyClass.java.1).
Important: Generated code for iBATIS2 requires that statement namespaces are enabled in your iBATIS configuration. See the Tasks After Running MyBatis Generator page for more information.