MybatisPlus整合
1.导入依赖
<dependency>
<groupId>
com.baomidou
</groupId>
<artifactId>
mybatis-plus-boot-starter
</artifactId>
<version>
3.2.0
</version>
</dependency>
2.
导入数据库驱动
https://mvnrepository.com/artifact/mysql/mysql-connector-java
<!--
导入
mysql
驱动
-->
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
<version>
8.0.17
</version>
</dependency>
3.
在
application.yml
配置数据源相关信息
spring:
datasource:
username:
root
password:
root
url:
jdbc:mysql://****
driver-class-name:
com.mysql.jdbc.Driver
mybatis-plus:
# mapper
文件扫描
mapper-locations:
classpath*:/mapper/**/*.xml
global-config:
db-config:
id-type:
auto
#
数据库主键自增
4.配置
MyBatis-Plus
包扫描:
1.
使用
@MapperScan
2.
告诉
MyBatis-Plus,Sql
映射文件位置
@MapperScan
(
"com.***.dao"
)
@SpringBootApplication
public class Test
Application
{
public static void
main
(String[] args)
{
SpringApplication.run(TestApplication.
class
,
args
);
}
}
具体过程参考官网:
https://baomidou.com/guide/install.html#release