JsonAutoDetect注解找不到错误
RedisConfig类代码:
package com.neo.SpringBoot.config;
import java.lang.reflect.Method;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.interceptor.KeyGenerator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.cache.RedisCacheManager;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
@Configuration
@EnableCaching
public class RedisConfig extends CachingConfigurerSupport {
public KeyGenerator keyGenerator() {
return new KeyGenerator() {
@Override
public Object generate(Object target, Method method, Object... params) {
StringBuilder sb = new StringBuilder();
sb.append(target.getClass().getName());
sb.append(method.getName());
for (Object object : params) {
sb.append(object.toString());
}
return sb.toString();
}
};
}
@SuppressWarnings("rawtypes")
@Bean
public CacheManager cacheManager(RedisTemplate redisTemplate) {
RedisCacheManager rcm = new RedisCacheManager(redisTemplate);
// 设置缓存的过期时间
// rcm.setDefaultExpiration(60);//秒
return rcm;
}
@Bean
public RedisTemplate<String, String> redisTemplate(RedisConnectionFactory factory) {
StringRedisTemplate template = new StringRedisTemplate(factory);
Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>(
Object.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
jackson2JsonRedisSerializer.setObjectMapper(om);
template.setValueSerializer(jackson2JsonRedisSerializer);
template.afterPropertiesSet();
return template;
}
}
错误提示:

pom.xml应引入:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
问题解决:
导入:import com.fasterxml.jackson.annotation.JsonAutoDetect;

JsonAutoDetect注解找不到错误的更多相关文章
- 之前的Android项目报错,新建Android项目报错,代码中找不到错误解决方案
打开一年前的东西,结果发现里面的android项目全部有个红叉,也找不到错误.新建一个项目也报错,首先确定自己的环境应该没问题,然后通过查看网上的资料,发现可能是debug的keystore到期啦. ...
- @slf4j注解找不到 log 变量
@slf4j注解找不到 log 变量 作者:oschina 来源:开源中国 时间:2017-10-11 23:05:02 我要评论 一. 检查是否添加在pom文件中添加依赖 org.projectlo ...
- 在程序出现问题,当找不到错误时,第一时间用try ,catch包括起来
在程序出现问题,当找不到错误时,第一时间用try ,catch包括起来,把错误找到.
- java架构之路-(SpringMVC篇)SpringMVC主要流程源码解析(下)注解配置,统一错误处理和拦截器
我们上次大致说完了执行流程,也只是说了大致的过程,还有中间会出错的情况我们来处理一下. 统一异常处理 比如我们的运行时异常的500错误.我们来自定义一个类 package com.springmvcb ...
- 在使用spring中的ContextConfiguration、test注解时出现的错误
错误: 在使用测试注解时出现ContextConfiguration注解和test注解无法正常导包使用的编译异常,如图: 解决办法: 将pom.xml文件中以下依赖管理 中的<scope> ...
- Eclipse中项目红叉但找不到错误解决方法
首先windows-show view-problems 根据地址查找错误 若提示: Description Resource Path Location TypeJava c ...
- jboss部署出现jboss.naming.context.java.rmi找不到错误
最近,在机器人程序中使用jmx,准备做个远程调用,客户端是web,部署在jboss上,本地测试的都好好的,发到预发布上就是不行, 错误描述: Failed to retrieve RMIServer ...
- jboss部署出现MarshalOutputStream找不到错误
在jboss EAP 6.3上部署一个war时,项目使用oracle coherence做为缓存,出现如下错误 Caused by: java.lang.NoClassDefFoundError: s ...
- springboot的注解声明过滤器配置错误导致拦截所有请求。
究其原因, 原来spring 扫包时候 扫了Webfilter 注解,注册了一次过滤匹配路径,扫了Component注解(又注册了一次过滤匹配路径,默认是全路径). Component注解后于WebF ...
随机推荐
- #mxnet# 权值共享
https://www.cnblogs.com/chenyliang/p/6847744.html Note:后记此权值共享非彼卷积共享.说的是layer实体间的参数共享. Introduction ...
- Camera2点击对焦实现2
https://www.aliyun.com/jiaocheng/22218.html 阿里云 > 教程中心 > android教程 > Camera2点击对焦实现 Cam ...
- selenium 模拟手机
import time from selenium import webdriver mobileEmulation = {'deviceName': 'Galaxy S5'} options = w ...
- 深入理解Word2Vec
Word2Vec Tutorial - The Skip-Gram Model,Skip-Gram模型的实现原理:http://mccormickml.com/2016/04/19/word2vec- ...
- phpStudy集成环境下 安装composer
报错提示: The "https://getcomposer.org/versions" file could not be downloaded: failed to open ...
- P2763 试题库问题(dinic)
P2763 试题库问题 dinic 搞个虚拟源点和汇点,瞎建建边就好辣. 偷张图↓↓ 如果没满流就是无解辣 输出方案咋办呢? 枚举每种类型,蓝后枚举它们的边 如果该边被使用了(通过判断反向边的流量), ...
- TF-IDF原理与实现
TF-IDF 原理与实现 目录 1.原理 2.伪代码 3.实现 1.原理 \[ TF-IDF = tf_{t,d} \times idf_{t}\\ tf_{t,d} = \frac{术语t在文档d中 ...
- 14: element ui 使用
1.1 element ui 基本使用 参考网址: http://element.eleme.io/#/zh-CN/component/button 1.初始一个vue项目并安装element ui ...
- Vmware 安装centos7与网络配置
一.下载linux镜像 下载地址:http://isoredirect.centos.org/centos/7/isos/x86_64/CentOS-7-x86_64-DVD-1804.iso 二.创 ...
- Codeforces 789D Weird journey - 欧拉路 - 图论
Little boy Igor wants to become a traveller. At first, he decided to visit all the cities of his mot ...