当前位置:网站首页>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 .
边栏推荐
- Export the altaro event log to a text file
- Go practice -- use redis in golang (redis and go redis / redis)
- mapbox尝鲜值之云图动画
- NG Textarea-auto-resize
- Go practice -- closures in golang (anonymous functions, closures)
- 2022.7.2 模拟赛
- Obtenir et surveiller les journaux du serveur distant
- PHP笔记超详细!!!
- ROS Compilation Principle
- Learn libcef together -- set cookies for your browser
猜你喜欢
随机推荐
【一起上水硕系列】Day 10
Win10 install pytullet and test
Latest version of source insight
Deep embedding and alignment of Google | protein sequences
2022.7.2 模拟赛
Niuke JS separator
获取并监控远程服务器日志
2022.7.2 simulation match
期末复习(DAY7)
mapbox尝鲜值之云图动画
今天很多 CTO 都是被幹掉的,因為他沒有成就業務
The request database reported an error: "could not extract resultset; SQL [n/a]; needed exception is org.hibernate.exception.sqlgram"
【一起上水硕系列】Day 7 内容+Day8
chromedriver对应版本下载
Pessimistic lock and optimistic lock of multithreading
Primary school campus IP network broadcasting - Design of primary school IP digital broadcasting system based on campus LAN
在PyCharm中配置使用Anaconda环境
Jetson AgX Orin platform porting ar0233 gw5200 max9295 camera driver
mysql启动报错:The server quit without updating PID file几种解决办法
Analysis of the example of network subnet division in secondary vocational school








