【Spring Boot】如何集成Redis,pcpop网
cpugpu芯片开发光刻机
智能终端演进
11
文件名:【Spring Boot】如何集成Redis,pcpop网
【Spring Boot】如何集成Redis
在pom.xml文件中导入spring data redis的maven坐标。 <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis</artifactId></dependency> 在application.yml文件中加入redis相关配置。 spring:redis:host: 192.168.xxx.xxxport: 6379password: xxxxdatabase: 0 在Bean管理中加入配置类RedisConfig。 package com.app.studypro.config;import lombok.extern.slf4j.Slf4j;import org.springframework.cache.annotation.CachingConfigurerSupport;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import org.springframework.data.redis.connection.RedisConnectionFactory;import org.springframework.data.redis.core.RedisTemplate;import org.springframework.data.redis.serializer.StringRedisSerializer;/*** Redis的配置信息** @author Administrator*/@Configuration@Slf4jpublic class RedisConfig extends CachingConfigurerSupport {@Beanpublic RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory connectionFactory) {RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>();log.info("Redis的KeySerializer设置为:{}", StringRedisSerializer.class);// 默认的Key序列化器为:JdkSerializationRedisSerializer// 将key的序列化器改为StringRedisSerializer,以便可以在Redis的key设置什么就显示什么,不进行转化redisTemplate.setKeySerializer(new StringRedisSerializer());redisTemplate.setConnectionFactory(connectionFactory);return redisTemplate;}}
同类推荐
-

【QT】其他常用控件2,securitykiss(qt常用控件及属性)
查看 -

【Qt】QLineEdit显示输入十六进制,位数不足时按照规则填充显示及每两个字符以空格填充,smart cover
查看 -

【Qt】顶层窗口和普通窗口区别以及用法,聚划算官网首页(qt 顶层窗口)
查看 -

【Qt之QColor】,dv6-6029tx(qt v6)
查看 -

【Qt开发流程】之程序主窗口,武尊神(qt主窗口打开子窗口)
查看 -

【RabbitMQ】初识消息队列 MQ,基于 Docker 部署 RabbitMQ,探索 RabbitMQ 基本使用,了解常见的消息类型,开奇网
查看 -

【RabbitMQ(day1)】RabbitMQ的概述和安装,三星w950(三星mr安装教程)
查看 -

【React】生命周期和钩子函数,金山毒霸极速版(金山毒霸功能介绍)
查看 -

【React学习】—SetState的使用(九),三星5508(setedit三星)
查看
控制面板
网站分类
搜索
最新留言
文章归档
网站收藏
友情链接