阅读更多
1.安装插件Eclipse中,Help->Eclipse Marketplace,搜索MyBatis,
安装一个扎红头绳小鸟的插件。
2.创建自动化配置文件generatorConfig.xml新建向导可找到模板,MyBatis->MyBatis Generator Configuration File,可得到一个带有主要配置不需求的模板,再根据自己的情况进行修改。如:
<?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> <context id="certTables"> <commentGenerator> <property name="suppressAllComments" value="true"/> </commentGenerator> <jdbcConnection connectionURL="jdbc:mysql://127.0.0.1:3306/your_dbname?serverTimezone=Asia/Shanghai" driverClass="com.mysql.cj.jdbc.Driver" password="your_passward" userId="your_userid"> </jdbcConnection> <javaTypeResolver> <property name="forceBigDecimals" value="false"/> </javaTypeResolver> <javaModelGenerator targetPackage="com.wallimn.iteye.sp.asset.bus.cert.model" targetProject="asset"> <property name="enableSubPackages" value="false"/> <property name="trimStrings" value="true"/> </javaModelGenerator> <sqlMapGenerator targetPackage="com.wallimn.iteye.sp.asset.bus.cert.model" targetProject="asset"> <property name="enableSubPackages" value="false"/> </sqlMapGenerator> <javaClientGenerator targetPackage="com.wallimn.iteye.sp.asset.bus.cert.dao" targetProject="asset" type="XMLMAPPER"> <property name="enableSubPackages" value="false"/> </javaClientGenerator> <table tableName="t_c_company"></table> </context> </generatorConfiguration>3.运行自动代码工具
在配置文件上点右键,Run As,。。。