当前位置:网站首页>Exception when introducing redistemplate: noclassdeffounderror: com/fasterxml/jackson/core/jsonprocessingexception
Exception when introducing redistemplate: noclassdeffounderror: com/fasterxml/jackson/core/jsonprocessingexception
2022-07-03 05:40:00 【Manon stayup】
Abnormal scenario
I want to test one today RedisTemplate The problem of , So use Spring Initializr Created a Spring Boot project , And introduced Spring Data Redis.
pom The corresponding package will be introduced to me in the file :
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
Customize RedisTemplate To configure , Set up Value The serialization method is GenericJackson2JsonRedisSerializer
@Configuration
public class RedisTemplateConfig {
@Bean
public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>();
redisTemplate.setConnectionFactory(redisConnectionFactory);
redisTemplate.setKeySerializer(new StringRedisSerializer());
redisTemplate.setValueSerializer(new GenericJackson2JsonRedisSerializer());
redisTemplate.setHashKeySerializer(new StringRedisSerializer());
redisTemplate.setHashValueSerializer(new GenericJackson2JsonRedisSerializer());
return redisTemplate;
}
}
Start the project after simple configuration , Direct prompt can't find Jackson Exceptions of related classes :java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/JsonProcessingException
Some error logs are intercepted below
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisTemplate' defined in class path resource [com/example/redistemplatesourcecodedemo/config/RedisTemplateConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.redis.core.RedisTemplate]: Factory method 'redisTemplate' threw exception; nested exception is java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/JsonProcessingException
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658)
resolvent
Looked at the spring-boot-starter-data-redis Of pom, There is really no introduction Jackson, Then we will introduce .
Spring The official already has one spring-boot-starter-json rely on , Let's lead in directly :
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-json</artifactId>
</dependency>
Start again , Problem solving .
Review of problems
This dependency was not added to the previous project , It's normal , Why ?
After some investigation , The original project introduced spring-boot-starter-web rely on , It is pom The dependency has been introduced .
边栏推荐
- ES 2022 正式发布!有哪些新特性?
- Source insight License Activation
- Why should we rewrite hashcode when we rewrite the equals method?
- Go practice - gorilla / handlers used by gorilla web Toolkit
- Shanghai daoning, together with American /n software, will provide you with more powerful Internet enterprise communication and security component services
- Installing altaro VM backup
- Redis使用Lua脚本简介
- 獲取並監控遠程服務器日志
- Jetson AGX Orin 平台移植ar0233-gw5200-max9295相机驱动
- kubernetes资源对象介绍及常用命令(五)-(ConfigMap)
猜你喜欢

Training method of grasping angle in grasping detection

Apache+PHP+MySQL环境搭建超详细!!!

Shanghai daoning, together with American /n software, will provide you with more powerful Internet enterprise communication and security component services

Differences among bio, NiO and AIO
![[function explanation (Part 2)] | [function declaration and definition + function recursion] key analysis + code diagram](/img/29/1644588927226a49d4b8815d8bc196.jpg)
[function explanation (Part 2)] | [function declaration and definition + function recursion] key analysis + code diagram

Webrtc native M96 version opening trip -- a reading code download and compilation (Ninja GN depot_tools)

Disassembly and installation of Lenovo r7000 graphics card
![[advanced pointer (1)] | detailed explanation of character pointer, pointer array, array pointer](/img/9e/a4558e8e53c9655cbc1a38e8c0536e.jpg)
[advanced pointer (1)] | detailed explanation of character pointer, pointer array, array pointer

期末复习(Day5)

Altaro set grandfather parent child (GFS) archiving
随机推荐
穀歌 | 蛋白序列的深度嵌入和比對
Source insight automatic installation and licensing
DEX net 2.0 for crawl detection
Transferring images using flask
Jetson AgX Orin platform porting ar0233 gw5200 max9295 camera driver
【一起上水硕系列】Day 7 内容+Day8
Explanation of variables, code blocks, constructors, static variables and initialization execution sequence of static code blocks of Ali interview questions
Go practice -- use JWT (JSON web token) in golang
SimpleITK学习笔记
Classification and discussion of plane grab detection methods based on learning
Beaucoup de CTO ont été tués aujourd'hui parce qu'il n'a pas fait d'affaires
[practical project] autonomous web server
Source insight operation manual installation trial
How do I migrate my altaro VM backup configuration to another machine?
mapbox尝鲜值之云图动画
Azure file synchronization of altaro: the end of traditional file servers?
Webrtc native M96 version opening trip -- a reading code download and compilation (Ninja GN depot_tools)
今天很多 CTO 都是被干掉的,因为他没有成就业务
Jetson AGX Orin 平台移植ar0233-gw5200-max9295相机驱动
Together, Shangshui Shuo series] day 9