Springboot+Mybatis整合基本代码

本文介绍了Springboot集成Mybatis的基础配置,包括数据库连接池Druid的设置,Thymeleaf模板引擎配置,以及Redis缓存的配置。此外,还讲解了如何使用雪花算法生成唯一ID,并开启了Mybatis的驼峰命名规则。
摘要由CSDN通过智能技术生成

Springboot+Mybatis整合基本代码
更新时间:2022-09-23 11:39:26发布时间:3小时前朗读
server:
port: 8089
spring:
datasource:
# 配置德鲁伊数据库连接池
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/personalblog?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
username: root
password: root
type: com.alibaba.druid.pool.DruidDataSource
thymeleaf:
prefix: classpath:/templates/
suffix: .html
mode: html
cache: false

配置redis

redis:
host: 127.0.0.1
database: 0
port: 6379
cache:
redis:
time-to-live: 1800000 #缓存数据的过期时间
#开启mybatis的驼峰命名
mybatis-plus:
configuration:
map-underscore-to-camel-case: true
# 控制台输出日志
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

雪花算法自动生成id

global-config:
db-config:
id-type: assign_id
logic-delete-field: flag # 全局逻辑删除的实体字段名(since 3.3.0,配置后可以忽略不配置步骤2)
logic-delete-value: 1 # 逻辑已删除值(默认为 1)
logic-not-delete-value: 0 # 逻辑未删除值(默认为 0)
personalBlog:
path: E:企业课项目软件Blogsrcmainresourcestemplatesstaticimagesupload
avatar:
path: …/static/images/avatar/

文章转自:Springboot+Mybatis整合基本代码_Java-答学网

作者:答学网,转载请注明原文链接:http://www.dxzl8.com/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值