NoClassDefFoundError: org/springframework/data/redis/connection/RedisStreamCommands
SpringBoot集成redission,参考官方文档集成:https://github.com/redisson/redisson/wiki/14.-%E7%AC%AC%E4%B8%89%E6%96%B9%E6%A1%86%E6%9E%B6%E6%95%B4%E5%90%88#141-spring%E6%A1%86%E6%9E%B6%E6%95%B4%E5%90%88
启动报错如下:
nested exception is java.lang.NoClassDefFoundError: org/springframework/data/redis/connection/RedisStreamCommands at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:324) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1378) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:575) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:846) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:863) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) at com.shimao.iot.heart.HeartApplication.main(HeartApplication.java:23) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
当前springBoot 版本2.1.2,引入的redission版本如下:
<!-- Redisson : 注意跟sringboot版本的匹配 --> <!-- https://github.com/redisson/redisson/tree/master/redisson-spring-data#spring-data-redis-integration --> <dependency> <groupId>org.redisson</groupId> <artifactId>redisson-spring-boot-starter</artifactId> <version>3.13.6</version> </dependency> <dependency> <groupId>org.redisson</groupId> <!-- for Spring Data Redis v.2.1.x --> <artifactId>redisson-spring-data-21</artifactId> <version>3.13.6</version> </dependency>
很奇怪,网上找了一篇文章:https://www.cnblogs.com/zkjblogs/p/13131232.html
版本降级,解决问题:
<!-- Redisson : 注意跟sringboot版本的匹配 --> <!-- https://github.com/redisson/redisson/tree/master/redisson-spring-data#spring-data-redis-integration --> <dependency> <groupId>org.redisson</groupId> <artifactId>redisson-spring-boot-starter</artifactId> <version>3.9.1</version> </dependency> <dependency> <groupId>org.redisson</groupId> <!-- for Spring Data Redis v.2.1.x --> <artifactId>redisson-spring-data-21</artifactId> <version>3.10.1</version> </dependency>