我从Java 8迁移到Java 11,编译顺利, 但是在运行带有jedis 3.0.0版本的spring boot 2应用程序时,
我遇到以下错误:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'getJedisConnectionFactory' defined in class resource path [/cache/configuration/RedisConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.redis.connection.jedis.JedisConnectionFactory]: Factory method 'getJedisConnectionFactory' threw exception; nested exception is java.lang.NoClassDefFoundError: redis / clients / util / Pool
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod (ConstructorResolver.java:591)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod (AbstractAutowireCapableBeanFactory.java:1246)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance (AbstractAutowireCapableBeanFactory.java:1096)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean (AbstractAutowireCapableBeanFactory.java:535)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean (AbstractAutowireCapableBeanFactory.java:495)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda $ doGetBean $ 0 (AbstractBeanFactory.java:317)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton (DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (AbstractBeanFactory.java:315)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:199)
at org.springframework.context.annotation.ConfigurationClassEnhancer $ BeanMethodInterceptor.resolveBeanReference (ConfigurationClassEnhancer.java:396)
at org.springframework.context.annotation.ConfigurationClassEnhancer $ BeanMethodInterceptor.intercept (ConfigurationClassEnhancer.java:368)
cache.configuration.RedisConfig $$ EnhancerBySpringCGLIB $$ e85c6eec.getJedisConnectionFactory (<generated>)
at configuration.RedisConfig.redisTemplate (RedisConfig.java:30)
at cache.configuration.RedisConfig $$ EnhancerBySpringCGLIB $$ e85c6eec.CGLIB $ redisTemplate $ 3 (<generated>)
cache.configuration.RedisConfig $$ EnhancerBySpringCGLIB $$ e85c6eec $$ FastClassBySpringCGLIB $$ a6f08934.invoke (<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper (MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer $ BeanMethodInterceptor.intercept (ConfigurationClassEnhancer.java:365)
at cache.configuration.RedisConfig $$ EnhancerBySpringCGLIB $$ e85c6eec.redisTemplate (<generated>)
at java.base / jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at java.base / jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at java.base / jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.base / java.lang.reflect.Method.invoke (Method.java:566)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate (SimpleInstantiationStrategy.java:154)
... more
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.redis.connection.jedis.JedisConnectionFactory]: Factory method 'getJedisConnectionFactory' threw exception; nested exception is java.lang.NoClassDefFoundError: redis / clients / util / Pool
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate (SimpleInstantiationStrategy.java:185)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod (ConstructorResolver.java:583)
... 138 more
Caused by: java.lang.NoClassDefFoundError: redis / clients / util / Pool
at cache.configuration.RedisConfig.getJedisConnectionFactory (RedisConfig.java:55)
at cache.configuration.RedisConfig $$ EnhancerBySpringCGLIB $$ e85c6eec.CGLIB $ getJedisConnectionFactory $ 0 (<generated>)
at cache.configuration.RedisConfig $$ EnhancerBySpringCGLIB $$ e85c6eec $$ FastClassBySpringCGLIB $$ a6f08934.invoke (<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper (MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer $ BeanMethodInterceptor.intercept (ConfigurationClassEnhancer.java:365)
谢谢
答案 0 :(得分:1)
Spring Boot 2与Jedis 2.9兼容,因此您将无法使用3.0.0。
有关更多信息,请参见https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#appendix-dependency-versions。