mapper(写sql语句增删改查)→service(在接口中创建方法,通过Imp实现方法)→contorller(调用service方法)→
contorller→service(创建接口user表的业务逻辑接口)→(创建一个实现类实现userservice)→mapper(创建接口连接数据库)→配置YML文件连接数据库
1.创建项目导入依赖
2.创建yml配置文件
spring:
datasource:
username: root
password: root
# 端口后面接数据库名
url: jdbc:mysql://127.0.0.1:3306/springboot_jdbc?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
driver-class-name: com.mysql.cj.jdbc.Driver
#将sql语句debug打印到控制台
logging:
level:
com.java.mapper: debug
3.创建contorller包.
创建user表的控制器
package com.java.controll