编程日记 后端使用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 @ 2024-09-15 21:49  vast_joy  阅读(28)  评论(0)    收藏  举报