java.lang.NoClassDefFoundError: org/apache/curator/framework/recipes/cache/TreeCacheListener

偶尔善良 提交于 2019-12-05 04:44:56

springboot整合dubbo时候,添加了一下依赖,讲道理,这几个jar包应该是够了的,但是就出现了如下异常,
在这里插入图片描述
java.lang.NoClassDefFoundError: org/apache/curator/framework/recipes/cache/TreeCacheListener
at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_191]
at java.lang.ClassLoader.defineClass(ClassLoader.java:763) ~[na:1.8.0_191]
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.8.0_191]
at java.net.URLClassLoader.defineClass(URLClassLoader.java:468) ~[na:1.8.0_191]
at java.net.URLClassLoader.access$100(URLClassLoader.java:74) ~[na:1.8.0_191]
at java.net.URLClassLoader$1.run(URLClassLoader.java:369) ~[na:1.8.0_191]
at java.net.URLClassLoader1.run(URLClassLoader.java:363) [na:1.8.0191]atjava.security.AccessController.doPrivileged(NativeMethod) [na:1.8.0191]atjava.net.URLClassLoader.findClass(URLClassLoader.java:362) [na:1.8.0191]atjava.lang.ClassLoader.loadClass(ClassLoader.java:424) [na:1.8.0191]atsun.misc.Launcher1.run(URLClassLoader.java:363) ~[na:1.8.0_191] at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_191] at java.net.URLClassLoader.findClass(URLClassLoader.java:362) ~[na:1.8.0_191] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_191] at sun.misc.LauncherAppClassLoader.loadClass(Launcher.java:349) ~[na:1.8.0_191]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_191]
at org.apache.dubbo.remoting.zookeeper.curator.CuratorZookeeperClient.createTargetDataListener(CuratorZookeeperClient.java:217) ~[dubbo-2.7.3.jar:2.7.3]
at org.apache.dubbo.remoting.zookeeper.curator.CuratorZookeeperClient.createTargetDataListener(CuratorZookeeperClient.java:52) ~[dubbo-2.7.3.jar:2.7.3]
at org.apache.dubbo.remoting.zookeeper.support.AbstractZookeeperClient.addDataListener(AbstractZookeeperClient.java:118) ~[dubbo-2.7.3.jar:2.7.3]
at org.apache.dubbo.configcenter.support.zookeeper.ZookeeperDynamicConfiguration.(ZookeeperDynamicConfiguration.java:62) ~[dubbo-2.7.3.jar:2.7.3]
at org.apache.dubbo.configcenter.support.zookeeper.ZookeeperDynamicConfigurationFactory.createDynamicConfiguration(ZookeeperDynamicConfigurationFactory.java:38) ~[dubbo-2.7.3.jar:2.7.3]
at org.apache.dubbo.configcenter.AbstractDynamicConfigurationFactory.getDynamicConfiguration(AbstractDynamicConfigurationFactory.java:33) ~[dubbo-2.7.3.jar:2.7.3]
at org.apache.dubbo.config.AbstractInterfaceConfig.getDynamicConfiguration(AbstractInterfaceConfig.java:314) ~[dubbo-2.7.3.jar:2.7.3]
at org.apache.dubbo.config.AbstractInterfaceConfig.prepareEnvironment(AbstractInterfaceConfig.java:289) ~[dubbo-2.7.3.jar:2.7.3]
at org.apache.dubbo.config.AbstractInterfaceConfig.startConfigCenter(AbstractInterfaceConfig.java:279) ~[dubbo-2.7.3.jar:2.7.3]
at org.apache.dubbo.config.AbstractInterfaceConfig.lambda$null7(AbstractInterfaceConfig.java:626) [dubbo2.7.3.jar:2.7.3]atjava.util.Optional.orElseGet(Optional.java:267) [na:1.8.0191]atorg.apache.dubbo.config.AbstractInterfaceConfig.lambda7(AbstractInterfaceConfig.java:626) ~[dubbo-2.7.3.jar:2.7.3] at java.util.Optional.orElseGet(Optional.java:267) ~[na:1.8.0_191] at org.apache.dubbo.config.AbstractInterfaceConfig.lambdauseRegistryForConfigIfNecessary8(AbstractInterfaceConfig.java:619) [dubbo2.7.3.jar:2.7.3]atjava.util.Optional.ifPresent(Optional.java:159) [na:1.8.0191]atorg.apache.dubbo.config.AbstractInterfaceConfig.useRegistryForConfigIfNecessary(AbstractInterfaceConfig.java:617) [dubbo2.7.3.jar:2.7.3]atorg.apache.dubbo.config.AbstractInterfaceConfig.checkRegistry(AbstractInterfaceConfig.java:207) [dubbo2.7.3.jar:2.7.3]atorg.apache.dubbo.config.ServiceConfig.checkAndUpdateSubConfigs(ServiceConfig.java:302) [dubbo2.7.3.jar:2.7.3]atorg.apache.dubbo.config.ServiceConfig.export(ServiceConfig.java:369) [dubbo2.7.3.jar:2.7.3]atorg.apache.dubbo.config.spring.ServiceBean.export(ServiceBean.java:336) [dubbo2.7.3.jar:2.7.3]atorg.apache.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:114) [dubbo2.7.3.jar:2.7.3]atorg.apache.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:60) [dubbo2.7.3.jar:2.7.3]atorg.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) [springcontext5.1.9.RELEASE.jar:5.1.9.RELEASE]atorg.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) [springcontext5.1.9.RELEASE.jar:5.1.9.RELEASE]atorg.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) [springcontext5.1.9.RELEASE.jar:5.1.9.RELEASE]atorg.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:402) [springcontext5.1.9.RELEASE.jar:5.1.9.RELEASE]atorg.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:359) [springcontext5.1.9.RELEASE.jar:5.1.9.RELEASE]atorg.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:896) [springcontext5.1.9.RELEASE.jar:5.1.9.RELEASE]atorg.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:552) [springcontext5.1.9.RELEASE.jar:5.1.9.RELEASE]atorg.springframework.boot.SpringApplication.refresh(SpringApplication.java:743)[springboot2.1.7.RELEASE.jar:2.1.7.RELEASE]atorg.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:390)[springboot2.1.7.RELEASE.jar:2.1.7.RELEASE]atorg.springframework.boot.SpringApplication.run(SpringApplication.java:312)[springboot2.1.7.RELEASE.jar:2.1.7.RELEASE]atorg.springframework.boot.SpringApplication.run(SpringApplication.java:1214)[springboot2.1.7.RELEASE.jar:2.1.7.RELEASE]atorg.springframework.boot.SpringApplication.run(SpringApplication.java:1203)[springboot2.1.7.RELEASE.jar:2.1.7.RELEASE]atcom.atguigu.gmall.BootUserServiceProviderApplication.main(BootUserServiceProviderApplication.java:15)[classes/:na]Causedby:java.lang.ClassNotFoundException:org.apache.curator.framework.recipes.cache.TreeCacheListeneratjava.net.URLClassLoader.findClass(URLClassLoader.java:382) [na:1.8.0191]atjava.lang.ClassLoader.loadClass(ClassLoader.java:424) [na:1.8.0191]atsun.misc.Launcher8(AbstractInterfaceConfig.java:619) ~[dubbo-2.7.3.jar:2.7.3] at java.util.Optional.ifPresent(Optional.java:159) ~[na:1.8.0_191] at org.apache.dubbo.config.AbstractInterfaceConfig.useRegistryForConfigIfNecessary(AbstractInterfaceConfig.java:617) ~[dubbo-2.7.3.jar:2.7.3] at org.apache.dubbo.config.AbstractInterfaceConfig.checkRegistry(AbstractInterfaceConfig.java:207) ~[dubbo-2.7.3.jar:2.7.3] at org.apache.dubbo.config.ServiceConfig.checkAndUpdateSubConfigs(ServiceConfig.java:302) ~[dubbo-2.7.3.jar:2.7.3] at org.apache.dubbo.config.ServiceConfig.export(ServiceConfig.java:369) ~[dubbo-2.7.3.jar:2.7.3] at org.apache.dubbo.config.spring.ServiceBean.export(ServiceBean.java:336) ~[dubbo-2.7.3.jar:2.7.3] at org.apache.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:114) ~[dubbo-2.7.3.jar:2.7.3] at org.apache.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:60) ~[dubbo-2.7.3.jar:2.7.3] at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE] at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE] at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE] at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:402) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE] at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:359) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:896) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:552) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:743) [spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:390) [spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) [spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1214) [spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1203) [spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE] at com.atguigu.gmall.BootUserServiceProviderApplication.main(BootUserServiceProviderApplication.java:15) [classes/:na] Caused by: java.lang.ClassNotFoundException: org.apache.curator.framework.recipes.cache.TreeCacheListener at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[na:1.8.0_191] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_191] at sun.misc.LauncherAppClassLoader.loadClass(Launcher.java:349) ~[na:1.8.0_191]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_191]


于是搜索了一波,在https://blog.csdn.net/u010938610/article/details/85318907一文中提到,需要添加一下依赖:

org.apache.curator
curator-recipes
2.8.0

添加以后确实把问题解决了,但是查看了该依赖下的包,里面的jar包与curator-framework依赖里面的一模一样,除了版本号不一样,在这里插入图片描述


如果你的程序出现了以上的异常,就添加上述说的依赖即可!如果有高人的看到的话,可以指点指点,为什么会这样?也许是新版本把一些类去掉了或者是怎么样。

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!