SpringBoot的增删改
首先创建一个Spring项目
创建成功后格式
在到pom.xml中添加依赖
<!-- 德鲁伊连接池 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.6</version>
</dependency>
<!-- 通用mapper -->
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper-spring-boot-starter</artifactId>
<version>2.1.5</version>
</dependency>
application.properties配置
server.port=8888
spring.datasource.url=jdbc:mysql://localhost:3306/ace?serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.hikari.idle-timeout=60000
spring.datasource.hikari.maximum-pool-size=30
spring.datasource.hikari.minimum-idle=10
mybatis.type-aliases-package=com.yzl.entity
如果是application.yml
server:
port: 8888
spring:
datasource:
url: jdbc:mysql://localhost:3306/ace?serverTimezone=UTC
username: root
password: root
driver-class-name: com.mysql.jdbc.Driver
hikari:
maximum-pool-size: 30
minimum-idle: 10
ApplicationBoot启动![Alt](https://i-blog.csdnimg.cn/blog_migrate/9aa7548301b09c04725df4c5c958f783.png)
页面 增删改(我偷懒下,只写了一个查询)
控制器Controller
实体类entity
Mapper 自定义方法
service
页面最终效果