提示:个人学习笔记
1、导入依赖
??在pom.xml中导入如下依赖: (基于springboot创建工程)
<!-- mybatis启动器-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.1</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<!-- mysql驱动包-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
2、配置文件
??在类路径下(即resources 下创建配置文件application.yaml )加载数据源信息
spring:
# 配置数据源信息
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/mybatis_plus?characterEncoding=utf-8&useSSL=false
username: root
password: root
3、连接数据库
??连接对应的数据库 右键要生成的表: 点击第一个选项MabatisX-Generator :
|