idea报错:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userController' defined in file [J:\Code\2023-4\TestCache\target\classes\com\example\testcache\contrller\UserController.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisAutoInit' defined in class path resource [com/alicp/jetcache/autoconfigure/RedisAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: redis/clients/jedis/UnifiedJedis
版本:
springBoot:2.7.10
jetcache:2.7.3
jdk:1.8
问题起因:使用springBoot整合jetcache,使用2.6.2可以完成,但是使用2.7.3就报错。
问题原因:jetcache 2.7.3所希望用的jedis的版本是 4.3.1 ,和我们springBoot提供的jedis不匹配。
jetcache建议我们使用的jedis版本
springboot提供的版本
问题解决;
加入如下配置:
<!--处理jedis的版本问题-->
<dependency>
<groupId>com.alicp.jetcache</groupId>
<artifactId>jetcache-starter-redis</artifactId>
<version>2.7.3</version>
<exclusions>
<exclusion>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>4.3.1</version>
</dependency>