springboot maven mybatis generate插件的使用
2021-01-23 18:14
标签:用户 includes alt 数据库链接 cto 映射文件 als false open springboot maven mybatis generate插件的使用 标签:用户 includes alt 数据库链接 cto 映射文件 als false open 原文地址:https://www.cnblogs.com/activestruggle/p/12881840.html主要步骤:
1.pom.xml
向dependencies>添加如下依赖
dependency>
groupId>org.mybatis.spring.bootgroupId>
artifactId>mybatis-spring-boot-starterartifactId>
version>2.1.2version>
dependency>
dependency>
groupId>mysqlgroupId>
artifactId>mysql-connector-javaartifactId>
version>8.0.19version>
dependency>
向build>标签下的plugins>标签添加如下配置
plugin>
groupId>org.mybatis.generatorgroupId>
artifactId>mybatis-generator-maven-pluginartifactId>
version>1.3.7version>
dependencies>
dependency>
groupId>mysqlgroupId>
artifactId>mysql-connector-javaartifactId>
version>8.0.19version>
dependency>
dependencies>
configuration>
configurationFile>${project.basedir}/src/main/resources/generateConfig.xmlconfigurationFile>
verbose>trueverbose>
overwrite>trueoverwrite>
configuration>
plugin>
向build>标签添加如下配置
resources>
resource>
directory>src/main/resourcesdirectory>
includes>
include>**/*.xmlinclude>
include>**/*.ymlinclude>
includes>
resource>
resources>
2.generateConfig.xml
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="context" targetRuntime="MyBatis3">
commentGenerator>
property name="suppressAllComments" value="true" />
property name="suppressDate" value="true" />
commentGenerator>
jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/springboot?characterEncoding=utf8&useSSL=false&serverTimezone=UTC&rewriteBatchedStatements=true"
userId="root" password="root">
jdbcConnection>
javaTypeResolver>
property name="forceBigDecimals" value="false" />
javaTypeResolver>
javaModelGenerator targetPackage="com.example.springbootmybatis.pojo"
targetProject=".\src\main\java">
property name="enableSubPackages" value="true" />
property name="trimStrings" value="true" />
javaModelGenerator>
sqlMapGenerator targetPackage="mapper"
targetProject=".\src\main\resources">
property name="enableSubPackages" value="true" />
sqlMapGenerator>
javaClientGenerator type="XMLMAPPER"
targetPackage="com.example.springbootmybatis.mapper" targetProject=".\src\main\java">
property name="enableSubPackages" value="true" />
javaClientGenerator>
table tableName="users" domainObjectName="">table>
context>
generatorConfiguration>
3.运行maven generator命令生成代码
上一篇:数组中数字出现的次数
文章标题:springboot maven mybatis generate插件的使用
文章链接:http://soscw.com/essay/45976.html