MyBatis can also generate code in the direction, can generate entity Class (PO), mapper interface and Mapper interface mapping files, can reduce the workload of our Code. The detailed steps are as follows
1, download MyBatis Build Rack Package tool Mybatis_generator_1.3.1.zip, unpack the rack package to the features, plugins folder of the package is copied to the Eclipse installation directory features, plugins folder. Restarting eclipse is OK.
After extracting the image as follows:
Eclipse path as shown in figure:
Copy Replacement as shown:
2, create Generatorconfig.xml file, install MyBatis can create Generatorconfig.xml
3, configure the Generatorconfig.xml configuration file, details as follows
[html] View plain copy <?xml version= "1.0" encoding= "UTF-8" ?> <! doctype generatorconfiguration public "-//mybatis.org//dtd mybatis generator configuration 1.0//en " " HTTP://MYBATIS.ORG/DTD/MYBATIS-GENERATOR-CONFIG_1_0.DTD " > <generatorConfiguration> <!-- <classPathEntry location= "D:\rep\mysql\mysql-connector-java\5.1.19\mysql-connector-java-5.1.19.jar" /> --> <classpathentry location= "D:\repo\com\oracle\ojdbc14\ 10.2.0.1.0\ojdbc14-10.2.0.1.0.jar " /> <context id=" Db2tables " targetruntime=" MyBatis3 "> < commentgenerator> < Property name= "SuppRessallcomments " value=" true " /> <property name= "Suppressdate" value= "true" /> </commentGenerator> <jdbcconnection driverclass= "Oracle.jdbc.driver.OracleDriver" connectionurl= "Jdbc:oracle:thin: @xxx. Xxx.xxx.xxx:1521:orcl4" userid= "xxx" password= "xxxx" /> <javaTypeResolver> <property name= " Forcebigdecimals " value=" false " />