NoSuchMethodError:将Spring Boot从1.5.3升级到2.1.6

时间:2019-12-02 11:18:01

标签: java spring spring-boot redis

我正在将Spring Boot从1.5.3版本升级到2.1.6版本。我添加了以下依赖项:

classpath('org.springframework.boot:spring-boot-gradle-plugin:2.1.6.RELEASE')
compile('org.springframework.boot:spring-boot-starter-data-redis')
  {
    exclude group: 'io.lettuce', module: 'lettuce-core'
  } 
compile('redis.clients:jedis:2.9.0')

我遇到以下错误:

原因:java.lang.NoSuchMethodError:org.springframework.data.redis.core.RedisTemplate.delete(Ljava / lang / Object;)V     在com.aonhewitt.upoint.cache.config.provider.impl.RedisCacheObjectProviderImpl.delete(RedisCacheObjectProviderImpl.java:292)     在com.aonhewitt.upoint.cache.util.DistributedCacheUtil.deleteCacheKey(DistributedCacheUtil.java:490)     在com.aonhewitt.upoint.cache.util.DistributedCacheUtil $$ FastClassBySpringCGLIB $$ 10d7e0fa.invoke()     在org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)     在org.springframework.aop.framework.CglibAopProxy $ DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:684)     在com.aonhewitt.upoint.cache.util.DistributedCacheUtil $$ EnhancerBySpringCGLIB $$ 15db3ca8.deleteCacheKey()     在com.aonhewitt.upoint.portal.configuration.util.ConfigurationParmUtil.manageClntParmKeysInRedis(ConfigurationParmUtil.java:49)处     在com.aonhewitt.portal.configuration.workengine.ConfigurationController.processRequest(ConfigurationController.java:234)     在com.aonhewitt.portal.configuration.workengine.ConfigurationGateway.processRequest(ConfigurationGateway.java:56)     在com.aonhewitt.portal.configuration.service.util.ConfigurationInit.load(ConfigurationInit.java:34)     在com.aonhewitt.upoint.core.ConfigMgrStartUp.init(ConfigMgrStartUp.java:59)     在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处     在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)     在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     在java.lang.reflect.Method.invoke(Method.java:498)     在org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor $ LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:363)处     在org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor $ LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:307)处     在org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitializatio

2 个答案:

答案 0 :(得分:0)

只需检查您的依赖项并删除旧版本的spring-data依赖项

答案 1 :(得分:0)

您已经获得了 starter-data-redis 和 jedis-client。 Jedis 与 spring-data-redis 一起使用。或者 starter-data-redis 自己工作。以下组合对我有用:

org.springframework.data:spring-data-redis:jar:2.4.8:compile redis.clients:jedis:jar:3.3.0:compile

参考链接:https://www.baeldung.com/spring-data-redis-tutorial