springBoot 自定义redisTemplate
package com.atirm.mybatismutiplesource.config.RedisConfig; import com.atirm.mybatismutiplesource.entity.User;
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.Jackson2JsonRedisSerializer; import java.net.UnknownHostException; /**
* 配置自定义的redisTemplate,并设置自动的序列化
*/
@Configuration
public class RedisConfig { @Bean
public RedisTemplate<Object, User> userRedisTemplate(RedisConnectionFactory redisConnectionFactory) throws UnknownHostException {
RedisTemplate<Object, User> template = new RedisTemplate<Object, User>();
template.setConnectionFactory(redisConnectionFactory);
// 默认是的用jdk序列化的,需要改成json
Jackson2JsonRedisSerializer<User> ser = new Jackson2JsonRedisSerializer<User>(User.class);
template.setDefaultSerializer(ser);
return template;
}
}
springBoot 自定义redisTemplate的更多相关文章
- springboot中RedisTemplate的使用
springboot中RedisTemplate的使用 参考 了解 Redis 并在 Spring Boot 项目中使用 Redis--以IBM为学习模板 springboot之使用redistemp ...
- SpringBoot自定义拦截器实现IP白名单功能
SpringBoot自定义拦截器实现IP白名单功能 转载请注明源地址:http://www.cnblogs.com/funnyzpc/p/8993331.html 首先,相关功能已经上线了,且先让我先 ...
- SpringBoot自定义错误信息,SpringBoot适配Ajax请求
SpringBoot自定义错误信息,SpringBoot自定义异常处理类, SpringBoot异常结果处理适配页面及Ajax请求, SpringBoot适配Ajax请求 ============== ...
- SpringBoot自定义错误页面,SpringBoot 404、500错误提示页面
SpringBoot自定义错误页面,SpringBoot 404.500错误提示页面 SpringBoot 4xx.html.5xx.html错误提示页面 ====================== ...
- springboot自定义错误页面
springboot自定义错误页面 1.加入配置: @Bean public EmbeddedServletContainerCustomizer containerCustomizer() { re ...
- SpringBoot自定义Filter
SpringBoot自定义Filter SpringBoot自动添加了OrderedCharacterEncodingFilter和HiddenHttpMethodFilter,当然我们可以自定 义F ...
- Springboot中RedisTemplate的操作
Springboot中RedisTemplate的操作 @Autowired private RedisTemplate redisTemplate; @Autowired private Strin ...
- springboot 自定义LocaleResolver切换语言
springboot 自定义LocaleResolver切换语言 我们在做项目的时候,往往有很多项目需要根据用户的需要来切换不同的语言,使用国际化就可以轻松解决. 我们可以自定义springboor中 ...
- SpringMVC拦截器与SpringBoot自定义拦截器
首先我们先回顾一下传统拦截器的写法: 第一步创建一个类实现HandlerInterceptor接口,重写接口的方法. 第二步在XML中进行如下配置,就可以实现自定义拦截器了 SpringBoot实现自 ...
随机推荐
- 关于Jsp页面的jstl标签的级联属性的异常。
使用SpringMVC框架时,当我做表单回显时. 情景描述.Employee 类有一个Department类的属性.这两个类存在多对一关联关系. 下面是Employee类的属性的定义. public ...
- JAVA二叉树递归构造、二叉树普通遍历及递归遍历
二叉树类: package com.antis.tree; public class BinaryTree { int data; //根节点数据 BinaryTree left; //左子树 Bin ...
- PHP语言开发微信公众平台(订阅号)之curl命令(补充)
在之前的一篇随笔中,博主在调用curl命令上传文件时会经常出现上传方法过时的情况.如下图所示: 所以,我们只需要把上传方法换成创建CURLFile 类即可.如下所示 $ch = curl_init() ...
- 调用save()方法,页面显示保存成功,但是数据库中没有值的原因
在DAO层调用save()方法,页面上显示成功,但是在数据库中查找时发现数据没有保存到数据库中的原因可能是: 1.Service层中是否在调用DAO层中的save()方法之前添加注解@Transact ...
- mybatis的resultMap自定义结果映射规则
dao接口 User myGetUserById(Integer id); sql xml自定义封装规则 <!--自定义某个javabean的封装规则 type:自定义规则的java类型 id: ...
- 以ADO形式操作mysql数据库
首先得需要一个连接mysql的helper类: public class MySqlHelper { #region [ Connection ] public static string conne ...
- ssh调用matplotlib绘图报错RuntimeError: Invalid DISPLAY variable
1.问题:在本地用matplotlib绘图可以,但是在ssh远程绘图的时候会报错 RuntimeError: Invalid DISPLAY variable 2.原因:matplotlib的默认ba ...
- 【题解】洛谷P1514 [NOIP2010TG] 引水入城(DFS+DP)
次元传送门:洛谷P1514 思路 可以证明如果有解 那么每个蓄水池可以覆盖到的干旱区必定是线段 证明: 举个栗子 8 9 8 7 9 7 6 9 6 明显到不了中间的点 如果不是连续的线段 中间肯定有 ...
- Faster Alternatives to glReadPixels and glTexImage2D in OpenGL ES
In the development of Shou, I’ve been using GLSL with NEON to manipulate image rotation, scaling and ...
- js 中 函数的返回值问题
var result=''; function searchByStationName( address ) { // map.clearOverlays();//清空原来的标注 var keywor ...