一、添加依赖
org.projectlombok
lombok
1.18.8
provided
tk.mybatis
mapper-spring-boot-starter
2.1.5
二、添加通用代码生成器插件
org.mybatis.generator
mybatis-generator-maven-plugin
1.3.6
src/main/resources/generator/generatorConfig.xml
true
true
mysql
mysql-connector-java
8.0.16
tk.mybatis
mapper
4.1.5
三、添加数据库配置属性
spring:
datasource:
url: jdbc:mysql://localhost:3306/hello?serverTimezone=UTC
username: root
password: wcc@090208%
#MySQL5.7.x及8.0以下 driver-class-name: com.mysql.jdbc.Driver
#MySQL8.x driver-class-name: com.mysql.cj.jdbc.Driver
driver-class-name: com.mysql.cj.jdbc.Driver
四、配置通用mapper
在resource中创建文件夹generator及配置文件config.properties和generatorConfig.xml
config.properties
#jdbc.driverClass=com.mysql.cj.jdbc.Driver
jdbc.driverClass=com.mysql.cj.jdbc.Driver
#jdbc.url=jdbc:mysql://localhost:3306/hello?serverTimezone=Asia/Shanghai
jdbc.url=jdbc:mysql://localhost:3306/hello?serverTimezone=UTC
jdbc.user=root
jdbc.password=wcc@090208%
# 表名
tableName=user
generatorConfig.xml
五、通过mybatis-generator生成代码
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)