maven mybatis反向工程插件

来源:互联网 发布:知乎页面显示不正常 编辑:程序博客网 时间:2024/05/21 21:46

1.引入插件

<plugin>    <groupId>org.mybatis.generator</groupId>    <artifactId>mybatis-generator-maven-plugin</artifactId>    <version>1.3.2</version>    <configuration>    <verbose>true</verbose>    <overwrite>true</overwrite>    <!--        配置文件所在地址-->    <configurationFile>xx/xxx.xml</configurationFile>    </configuration></plugin>

2.填写配置文件

<?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>    <!--指定jdbc驱动jar-->    <classPathEntry location="x:\xx\xx.jar"/>    <!--创建生成任务-->    <context id="mysqlTables" targetRuntime="MyBatis3">        <commentGenerator>            <!-- 是否去除自动生成的注释 true:不生成 false:生成 -->            <property name="suppressAllComments" value="false" />        </commentGenerator><!--        数据库连接参数设置        driverClass  数据库驱动class        connectionURL url连接协议        userId  用户名        password 密码-->        <jdbcConnection driverClass="com.mysql.jdbc.Driver"                        connectionURL="xxx"                        userId="xxx" password="xxx"/>        <!--指定生成的类型为java类型,避免数据库中number等类型字段 -->        <javaTypeResolver>            <property name="forceBigDecimals" value="false"/>        </javaTypeResolver>        <!--自动生成的实体的存放包路径         注意:targetProject指定文件夹必须存在-->        <javaModelGenerator targetPackage="com.example.demo.model.entity"                            targetProject="doc/src">            <property name="enableSubPackages" value="true"/>            <property name="trimStrings" value="true"/>        </javaModelGenerator>        <!--自动生成的*Mapper.xml文件存放路径 -->        <sqlMapGenerator targetPackage="mapper"                         targetProject="doc">            <property name="enableSubPackages" value="true"/>        </sqlMapGenerator>        <!--自动生成的*Mapper.java存放路径 -->        <javaClientGenerator type="XMLMAPPER" targetPackage="com.example.demo.model.dao"                             targetProject="doc/src">            <property name="enableSubPackages" value="true"/>        </javaClientGenerator>        <table tableName="%"/>    </context></generatorConfiguration>