【Spring Boot】如何集成Redis,pcpop网
cpugpu芯片开发光刻机
智能终端演进
14
文件名:【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;}}
同类推荐
-

【Proteus仿真】【Arduino单片机】直流电机和步进电机,i718(proteus仿真直流电机的控制)
查看 -

【Q2—30min】,www.pcpop.com(q2002.c-m)
查看 -

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

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

【Qt之QTableWidget和QTreeWidget】树悬停、选择样式及表格表头和首行间隔线,泡泡网笔记本
查看 -

【Qt之QtXlsx模块】安装及使用,ap2496
查看 -

【React】03.脚手架的进阶应用,索尼爱立信w550c(索尼爱立信w508)
查看 -

【React入门实战】实现Todo代办,foxit reader 3.0
查看 -

【React基础全篇】,华硕n10e(华硕n10jseries)
查看
控制面板
网站分类
搜索
最新留言
文章归档
网站收藏
友情链接