编程日记 后端使用redis

编程日记 后端使用redis

问题:在写伙伴匹配系统的时候,要使用redis存储数据,需要在xml文件中设置spring.session.tore-type=redis

但是3.x版本的spring不再有这个参数。

那么怎么设置是否使用redis存储呢?只要导入了org.springframework.session包那就启用,不导入就不启用

https://www.jb51.net/program/314300rvw.htm

image-20240826133924741

而且3.x的spring把一些参数写到data里了,最终xml如下

spring:
  profiles:
    active: dev
  application:
    name: user-center
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    username: root
    password: 1234
    url: jdbc:mysql://localhost:3306/haole
  #session失效时间(分钟)
  session:
    timeout: 86400
    

  mvc:
    pathmatch:
      matching-strategy: ant_path_matcher
  #redis
  data:
    redis:
      port: 6379
      host: localhost
      database: 0
posted @   vast_joy  阅读(12)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 张高兴的大模型开发实战:(一)使用 Selenium 进行网页爬虫
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
点击右上角即可分享
微信分享提示