<?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">
<!--
拷入IDEA中XML文件,Line13,Line21,Line25,Line30,Line35
以及后续数据库对应表名需要修改
-->
<generatorConfiguration>
<!--数据库驱动包路径 -->
<classPathEntry location="D:\mine\maven\repo\mysql\mysql-connector-java\8.0.23\mysql-connector-java-8.0.23.jar"/>
<context id="DB2Tables" targetRuntime="MyBatis3">
<!--关闭注释 -->
<commentGenerator>
<property name="suppressAllComments" value="true"/>
</commentGenerator>
<!--数据库连接信息 -->
<!-- <jdbcConnection driverClass="com.mysql.cj.jdbc.Driver" connectionURL="${spring.datasource.url}" userId="${spring.datasource.username}" password="${spring.datasource.password}">-->
<jdbcConnection driverClass="com.mysql.cj.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/big_strong?serverTimezone=UTC" userId="root" password="root">
</jdbcConnection>
<!--生成的model 包路径 -->
<javaModelGenerator targetPackage="com.example.demo.pojo" targetProject="src/main/java">
<property name="enableSubPackages" value="ture"/>
<property name="trimStrings" value="false"/>
</javaModelGenerator>
<!--生成xml mapper文件 路径 -->
<sqlMapGenerator targetPackage="mapper" targetProject="src/main/resources">
<property name="enableSubPackages" value="ture"/>
</sqlMapGenerator>
<!-- 生成的Dao接口 的包路径 -->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.example.demo.mapper" targetProject="src/main/java">
<property name="enableSubPackages" value="ture"/>
</javaClientGenerator>
<!--对应数据库表名 -->
<table tableName="role" domainObjectName="Role" enableCountByExample="false"
enableSelectByExample="false" enableUpdateByExample="false" enableDeleteByExample="false">
<property name="useActualColumnNames" value="true"/>
</table>
<table tableName="permission" domainObjectName="Permission" enableCountByExample="false"
enableSelectByExample="false" enableUpdateByExample="false" enableDeleteByExample="false">
<property name="useActualColumnNames" value="true"/>
</table>
<table tableName="user_role" domainObjectName="UserRole" enableCountByExample="false"
enableSelectByExample="false" enableUpdateByExample="false" enableDeleteByExample="false">
<property name="useActualColumnNames" value="true"/>
</table>
<table tableName="role_permission" domainObjectName="RolePermission" enableCountByExample="false"
enableSelectByExample="false" enableUpdateByExample="false" enableDeleteByExample="false">
<property name="useActualColumnNames" value="true"/>
</table>
</context>
</generatorConfiguration>
对应的POM
<!-- Mybatis generator代码生成插件 配置 -->
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.1</version>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.15</version>
</dependency>
</dependencies>
<configuration>
<configurationFile>${basedir}/src/main/resources/generatorConfig.xml</configurationFile>
<overwrite>true</overwrite>
<verbose>true</verbose>
</configuration>
</plugin>