Error creating bean with name ‘redisTemplate‘ defined in class path resource [xx/RedisConfig.class]

Error creating bean with name ‘redisTemplate’ defined in class path resource [xx/RedisConfig.class]

1. Problem description

When redis is used in the project, the following errors are reported:

2. Problem analysis

From the error reporting factory method ‘redisconnectionfactory’ thread exception; Needed exception is java.lang.noclassdeffounderror: org/Apache/commons/pool2/impl/genericobjectpoolconfig get key information. NoClassDefFoundError: it is caused by that the JVM cannot load the class or cannot find the class at compile time
reasons for NoClassDefFoundError:
1) one reason is that static variables cannot be loaded
2) if jars are not added to classpath and Maven projects in the project, they need to be checked according to the project conditions

3. Problem handling

The spring boot starter data redis package referenced in the project. By default, spring boot starter data redis uses lettuce as the redis client, and the underlying layer of lettuce is implemented by netty. Lettuce is a scalable thread safe redis client that supports synchronization, asynchronous and responsive modes. Multiple threads can share a connection instance without worrying about multithreading concurrency. The use of lettuce requires the configuration of thread pool. You also need to reference the following packages:

Read More: