java jedis jar_因缺少jedis.jar包报"java.lang.NoSuchMethodError: redis.clients.jedis.JedisPool.

本文介绍如何将Dubbo 2.5.3项目的注册中心从Zookeeper切换到Redis,并详细说明了遇到的`NoSuchMethodError`,提供了解决方案,包括添加正确依赖和下载对应版本的Jedis和commons-pool库。
摘要由CSDN通过智能技术生成

一、问题描述

项目是基于dubbo的2.5.3版本,将注册中心zookeeper(zookeeper://127.0.0.1:2181)改为redis的(redis://127.0.0.1:6379),添加redis依赖关系,启动系统报异常“java.lang.NoSuchMethodError: redis.clients.jedis.JedisPool.(Lorg/apache/commons/pool/impl/GenericObjectPool$Config;Ljava/lang/String;II)V”,具体错误日志如下所示java.lang.NoSuchMethodError: redis.clients.jedis.JedisPool.(Lorg/apache/commons/pool/impl/GenericObjectPool$Config;Ljava/lang/String;II)V@b@    at com.alibaba.dubbo.registry.redis.RedisRegistry.(RedisRegistry.java:130)@b@    at com.alibaba.dubbo.registry.redis.RedisRegistryFactory.getRegistry(RedisRegistryFactory.java:30)@b@    at com.alibaba.dubbo.registry.RegistryFactory$Adpative.getRegistry(RegistryFactory$Adpative.java)@b@    at com.alibaba.dubbo.registry.integration.RegistryProtocol.getRegistry(RegistryProtocol.java:190)@b@    at com.alibaba.dubbo.registry.integration.RegistryProtocol.export(RegistryProtocol.java:109)@b@    at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper.export(ProtocolFilterWrapper.java:53)@b@    at com.alibaba.dubbo.rpc.protocol.ProtocolListenerWrapper.export(ProtocolListenerWrapper.java:54)@b@    at com.alibaba.dubbo.rpc.Protocol$Adpative.export(Protocol$Adpative.java)@b@    at com.alibaba.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:485)@b@    at com.alibaba.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:281)@b@    at com.alibaba.dubbo.config.ServiceConfig.doExport(ServiceConfig.java:242)@b@    at com.alibaba.dubbo.config.ServiceConfig.export(ServiceConfig.java:143)@b@    at com.alibaba.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:109)@b@    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:151)@b@    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:128)@b@    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:331)@b@    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:773)@b@    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:483)@b@    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)@b@    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)@b@    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)@b@    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135)@b@    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)@b@    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)@b@    at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)@b@    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)@b@    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)@b@    at org.apache.catalina.startup.Embedded.start(Embedded.java:825)@b@    at org.codehaus.mojo.tomcat.AbstractRunMojo.startContainer(AbstractRunMojo.java:558)@b@    at org.codehaus.mojo.tomcat.AbstractRunMojo.execute(AbstractRunMojo.java:255)@b@    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)@b@    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)@b@    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)@b@    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)@b@    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)@b@    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)@b@    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)@b@    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)@b@    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)@b@    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)@b@    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:534)@b@    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)@b@    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)@b@    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)@b@    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)@b@    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)@b@    at java.lang.reflect.Method.invoke(Method.java:597)@b@    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)@b@    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)@b@    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)@b@    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)@b@2016-11-15 12:14:38 org.apache.catalina.core.StandardContext listenerStart@b@严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener@b@java.lang.NoSuchMethodError: redis.clients.jedis.JedisPool.(Lorg/apache/commons/pool/impl/GenericObjectPool$Config;Ljava/lang/String;II)V@b@    at com.alibaba.dubbo.registry.redis.RedisRegistry.(RedisRegistry.java:130)@b@    at com.alibaba.dubbo.registry.redis.RedisRegistryFactory.getRegistry(RedisRegistryFactory.java:30)@b@    at com.alibaba.dubbo.registry.RegistryFactory$Adpative.getRegistry(RegistryFactory$Adpative.java)@b@    at com.alibaba.dubbo.registry.integration.RegistryProtocol.getRegistry(RegistryProtocol.java:190)@b@    at com.alibaba.dubbo.registry.integration.RegistryProtocol.export(RegistryProtocol.java:109)@b@    at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper.export(ProtocolFilterWrapper.java:53)@b@    at com.alibaba.dubbo.rpc.protocol.ProtocolListenerWrapper.export(ProtocolListenerWrapper.java:54)@b@    at com.alibaba.dubbo.rpc.Protocol$Adpative.export(Protocol$Adpative.java)@b@    at com.alibaba.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:485)@b@    at com.alibaba.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:281)@b@    at com.alibaba.dubbo.config.ServiceConfig.doExport(ServiceConfig.java:242)@b@    at com.alibaba.dubbo.config.ServiceConfig.export(ServiceConfig.java:143)@b@    at com.alibaba.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:109)@b@    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:151)@b@    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:128)@b@    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:331)@b@    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:773)@b@    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:483)@b@    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)@b@    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)@b@    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)@b@    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135)@b@    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)@b@    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)@b@    at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)@b@    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)@b@    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)@b@    at org.apache.catalina.startup.Embedded.start(Embedded.java:825)@b@    at org.codehaus.mojo.tomcat.AbstractRunMojo.startContainer(AbstractRunMojo.java:558)@b@    at org.codehaus.mojo.tomcat.AbstractRunMojo.execute(AbstractRunMojo.java:255)@b@    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)@b@    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)@b@    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)@b@    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)@b@    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)@b@    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)@b@    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)@b@    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)@b@    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)@b@    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)@b@    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:534)@b@    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)@b@    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)@b@    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)@b@    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)@b@    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)@b@    at java.lang.reflect.Method.invoke(Method.java:597)@b@    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)@b@    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)@b@    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)@b@    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)@b@2016-11-15 12:14:38 org.apache.catalina.core.StandardContext start@b@严重: Error listenerStart

二、解决方法

1. 由于dubbo的2.5.3版本依赖的redis版本是2.0.0,添加正确的依赖关系如下@b@      redis.clients@b@       jedis@b@       2.0.0@b@

2. 离线或在线online下载jedis-2.0.0的jar和pom文件(到本站的maven参考下载,或到maven2官网下载)

3. 因为jedis-2.0.0版本依赖的commons-pool-1.5.5,同时下载其jar和pom文件

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值