This article is a mirror article of machine translation, please click here to jump to the original article.

View: 14767|Reply: 0

[Source] Error creating bean with name 'stringRedisTemplate' defined in...

[Copy link]
Posted on 3/11/2019 1:31:52 PM | | |
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'stringRedisTemplate' defined in class path resource [org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration.class]: Unsatisfied dependency expressed through method 'stringRedisTemplate' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisConnectionFactory' defined in class path resource [org/springframework/boot/autoconfigure/data/redis/LettuceConnectionConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory]: Factory method 'redisConnectionFactory' threw exception; nested exception is java.lang.NoClassDefFoundError: org/apache/commons/pool2/impl/GenericObjectPoolConfig
Environment:

spring-boot-starter-data-redis 2.1.1.RELEASE version

spring-boot-starter-parent 2.1.1.RELEASE version

jdk 1.8

POM. XML configuration




Error report from starting the project, analysis of the cause of the error:

springboot 2.X version uses lettuce connection pool toReplacejedis。 Lettuce and Jedis are both client programs that connect to Redis Server.Jedis is directly connected to the redis server in a multi-threaded environmentNon-threaded safety, unless connection pools are used, adding physical connections for each Jedis faction.Lettuce is based on Netty's power connection, which can be accessed concurrently between multiple threads, and Thread safety, which meets the requirements for concurrent access in a multi-threaded environment, and it is a scalable design, so if there is not enough connection instances, you can add connection instances as needed.

Solution:

springboot2. X uses lettuce to connect to the pool by default, and commons-pool2 needs to be introduced



DigressionIf you get an error like this:

Consider defining a bean of type 'org.springframework.data.redis.core.RedisTemplate' in your configuration.

The injection point has the following annotations:
        - @org.springframework.beans.factory.annotation.Autowired(required=true)
Please refer to:

The exception is resolved by injecting the RedisTemplate instance in SpringBoot
https://www.itsvse.com/thread-7224-1-1.html
(Source: Architect_Programmer)






Previous:The exception is resolved by injecting the RedisTemplate instance in SpringBoot
Next:Solve the problem of garbled characters in Spring boot Chinese
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com