数据库访问的配置:
1.导入JDBC场景

2.导入数据库驱动

3.在配置文件中加入信息

Druid数据源:
1、引入依赖

2.配置数据源信息

3.开启sql监控功能

4.开启web监控功能

5.开启防火墙功能
只需dataSource.setFilters("stat, wall");(见步骤2)
Druid数据源配置(经典白学):
只需在pom中配置druid的starter,即可省略前面的所有配置:

前面关于druid数据源监控页的各种配置,直接在application.yaml中配置即可,如下:

SB整合Mybatis(注解):
1.引入依赖

2.准备表以及Bean

3.准备Mapper

4.准备Service

5.在Controller中写这样一个方法进行测试

6.输入如下网址(http://localhost:8080/dept?did=1),可以发现已经通过注解方式整合好了Mybatis

网友评论