⚡spring boot实现增删改查
springboot特点:DI依赖注入、ioc控制反转、aop面向切面。
创建包bean、controller、mapper、service,mybatis、然后在各包下创建对应的文件,

1、在controller层创建前后端交互

注:在类名上面加@controller注解。
2、service层

3、实现service

注:在service的实现层中,在类名上面添加注解@service
4、mapper层

在mapper的类上面添加注解@mapper,(@component)
5、在mapper.xml中放sql语句

application.yml:
server:
port: 8080
spring:
datasource:
username: root
password: gsl
url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=UTC
driver-class-name: com.mysql.jdbc.Driver
#获取到所有的mapper.xml文件
mybatis:
mapper-locations: classpath:mybatis/*Mapper.xml
type-aliases-package: com.example.bean
# 启动驼峰自动转换
configuration:
map-underscore-to-camel-case: true
SpringBoot整合Mybatis实现增删改查操作
1282

被折叠的 条评论
为什么被折叠?



