1.引入依赖
<!-- mybatis-plus -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.3.1</version>
</dependency>
<!-- mybatis-plus代码生成器 -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>3.3.1.tmp</version>
</dependency>
<!-- mybatisPlus Freemarker 模版引擎 -->
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
</dependency>
<!-- mysql连接 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
2.进行配置
# mybatis配置 mybatis-plus: # xml文件路径 mapper-locations: classpath:mapper/*/*.xml # 实体类路径 type-aliases-package: com.asurplus.*.entity configuration: # 驼峰转换 map-underscore-to-camel-case: true # 是否开启缓存 cache-enabled: false # 打印sql log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 全局配置 global-config: # 数据库字段驼峰下划线转换 db-column-underline: true # id自增类型(数据库id自增) id-type: 0
3.引入代码生成工具类即可
package com.asurplus.common.mybatis; import com.baomidou.mybatisplus.core.exceptions.MybatisPlusException; import com.baomidou.mybatisplu