One of the ways to use the Maven plugin
<Build> <Plugins> <plugin> <groupId>Org.mybatis.generator</groupId> <Artifactid>Mybatis-generator-maven-plugin</Artifactid> <version>1.3.2</version> <Configuration> <ConfigurationFile>Src/main/resources/generatorconfig.xml</ConfigurationFile> <verbose>True</verbose> <Overwrite>True</Overwrite> </Configuration> <executions> <Execution> <ID>Generate MyBatis Artifacts</ID> <Goals> <goal>Generate</goal> </Goals> </Execution> </executions> <Dependencies> <Dependency> <groupId>Org.mybatis.generator</groupId> <Artifactid>Mybatis-generator-core</Artifactid> <version>1.3.2</version> </Dependency> <Dependency> <groupId>Mysql</groupId> <Artifactid>Mysql-connector-java</Artifactid> <version>5.1.30</version> <Scope>Runtime</Scope> </Dependency> </Dependencies> </plugin> </Plugins> </Build>
<?XML version= "1.0" encoding= "UTF-8"?><!DOCTYPE generatorconfiguration Public "-//mybatis.org//dtd mybatis Generator Configuration 1.0//en" "Htt P://mybatis.org/dtd/mybatis-generator-config_1_0.dtd "><generatorconfiguration> <!--<classpathentry location= "C:/oracle/middleware/wlserver_10.3/server/lib/ojdbc6.jar"/> - <ContextID= "my"Targetruntime= "MyBatis3"> <Commentgenerator> < Propertyname= "Suppressdate"value= "false"/> < Propertyname= "Suppressallcomments"value= "true"/> </Commentgenerator> <jdbcconnectionDriverclass= "Com.mysql.jdbc.Driver"Connectionurl= "Jdbc:mysql://211.144.120.229:3306/drtest?characterencoding=utf-8"userId= "Dradmin"Password= "Drpass123"/> <JavamodelgeneratorTargetpackage= "Foo"Targetproject= "D:/workspace/zzzz-core/src/main/java"> < Propertyname= "Enablesubpackages"value= "true"/> < Propertyname= "Trimstrings"value= "true"/> </Javamodelgenerator> <SqlmapgeneratorTargetpackage= "Foo"Targetproject= "D:/workspace/zzzz-core/src/main/java"> < Propertyname= "Enablesubpackages"value= "true"/> </Sqlmapgenerator> <JavaclientgeneratorTargetpackage= "Foo"Targetproject= "D:/workspace/zzzz-core/src/main/java"type= "Xmlmapper"> < Propertyname= "Enablesubpackages"value= "true"/> </Javaclientgenerator> <!--<table tablename= "T_fee_agtbill" domainobjectname= "Feeagentbill" enablecountbyexample= "false" EnableU Pdatebyexample= "false" enabledeletebyexample= "false" enableselectbyexample= "false" Selectbyexa Mplequeryid= "false"/> - <TableTableName= "Hf_user"Domainobjectname= "Hfuser"Enablecountbyexample= "false"Enableupdatebyexample= "false"Enabledeletebyexample= "false"Enableselectbyexample= "false"Selectbyexamplequeryid= "false"> <!--<columnrenamingrule searchstring= "^d_" replacestring= ""/> - </Table> </Context></generatorconfiguration>
MyBatis generate automatically generates entity DAO and XML files