<?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="test" targetRuntime="MyBatis3"> <commentGenerator> <!-- 是否去除自动生成的注释 true:是 : false:否 --> <property name="suppressAllComments" value="true" /> </commentGenerator> <!--数据库链接URL,用户名、密码 --> <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/crmpro" userId="root" password="toor"> </jdbcConnection> <javaTypeResolver> <!-- This property is used to specify whether MyBatis Generator should force the use of java.math.BigDecimal for DECIMAL and NUMERIC fields, --> <property name="forceBigDecimals" value="false" /> </javaTypeResolver> <!-- 生成模型的包名和位置 --> <javaModelGenerator targetPackage="bean" targetProject="target"> <property name="enableSubPackages" value="true" /> <property name="trimStrings" value="true" /> </javaModelGenerator> <!-- 生成映射文件的包名和位置 --> <sqlMapGenerator targetPackage="mapper" targetProject="target"> <property name="enableSubPackages" value="true" /> </sqlMapGenerator> <!-- 生成DAO的包名和位置 --> <javaClientGenerator type="XMLMAPPER" targetPackage="mapper" implementationPackage="cn.blog.service.impl" targetProject="target"> <property name="enableSubPackages" value="true" /> </javaClientGenerator> <!-- 要生成哪些表 --> <table tableName="analysis" domainObjectName="Analysis"></table> <table tableName="archives" domainObjectName="Archives"></table> <table tableName="attachment" domainObjectName="Attachment"></table> <table tableName="baoxiao" domainObjectName="BaoXiao"></table> <table tableName="customer" domainObjectName="Customer"></table> <table tableName="dept" domainObjectName="Dept"></table> <table tableName="email" domainObjectName="Email"></table> <table tableName="employee" domainObjectName="Employee"></table> <table tableName="forumpost" domainObjectName="ForumPost"></table> <table tableName="function" domainObjectName="Function"></table> <table tableName="level" domainObjectName="Level"></table> <table tableName="module" domainObjectName="Module"></table> <table tableName="msg" domainObjectName="Msg"></table> <table tableName="notice" domainObjectName="Notice"></table> <table tableName="position" domainObjectName="Position"></table> <table tableName="project" domainObjectName="Project"></table> <table tableName="role" domainObjectName="Role"></table> <table tableName="sources" domainObjectName="Sources"></table> <table tableName="task" domainObjectName="Task"></table> </context> </generatorConfiguration>
在Maven Projects的Execute Maven Goal内执行命令:mybatis-generator:generate
检查目标路径,已生成对应的class、interface和映射文件。