加完Nacos配置后报错
信息: [DUBBO] The registry[<dubbo:registry address="nacos://localhost:8848" protocol="nacos" port="8848" />] will be used as the config center, dubbo version: 2.7.8, current host: 192.168.0.103
八月 09, 2023 1:04:59 下午 org.apache.dubbo.common.logger.jcl.JclLogger error
严重: [DUBBO] org.slf4j.Logger, dubbo version: 2.7.8, current host: 192.168.0.103
ErrCode:-400, ErrMsg:org.slf4j.Logger
at com.alibaba.nacos.api.config.ConfigFactory.createConfigService(ConfigFactory.java:46)
at com.alibaba.nacos.api.NacosFactory.createConfigService(NacosFactory.java:44)
at org.apache.dubbo.configcenter.support.nacos.NacosDynamicConfiguration.buildConfigService(NacosDynamicConfiguration.java:103)
at org.apache.dubbo.configcenter.support.nacos.NacosDynamicConfiguration.<init>(NacosDynamicConfiguration.java:95)
at org.apache.dubbo.configcenter.support.nacos.NacosDynamicConfigurationFactory.createDynamicConfiguration(NacosDynamicConfigurationFactory.java:39)
at org.apache.dubbo.common.config.configcenter.AbstractDynamicConfigurationFactory.lambda$getDynamicConfiguration$0(AbstractDynamicConfigurationFactory.java:39)
at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)
at org.apache.dubbo.common.config.configcenter.AbstractDynamicConfigurationFactory.getDynamicConfiguration(AbstractDynamicConfigurationFactory.java:39)
at org.apache.dubbo.common.config.configcenter.DynamicConfiguration.getDynamicConfiguration(DynamicConfiguration.java:224)
at org.apache.dubbo.config.bootstrap.DubboBootstrap.prepareEnvironment(DubboBootstrap.java:1034)
at org.apache.dubbo.config.bootstrap.DubboBootstrap.startConfigCenter(DubboBootstrap.java:623)
at org.apache.dubbo.config.bootstrap.DubboBootstrap.initialize(DubboBootstrap.java:521)
at org.apache.dubbo.config.bootstrap.DubboBootstrap.start(DubboBootstrap.java:896)
at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onContextRefreshedEvent(DubboBootstrapApplicationListener.java:59)
at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onApplicationContextEvent(DubboBootstrapApplicationListener.java:52)
at org.apache.dubbo.config.spring.context.OneTimeExecutionApplicationContextEventListener.onApplicationEvent(OneTimeExecutionApplicationContextEventListener.java:40)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:883)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)
at org.apache.dubbo.container.spring.SpringContainer.start(SpringContainer.java:50)
at org.apache.dubbo.container.Main.main(Main.java:90)
at org.cyf.App.main(App.java:14)
Caused by: java.lang.NoClassDefFoundError: org/slf4j/Logger
at com.alibaba.nacos.client.config.NacosConfigService.<clinit>(NacosConfigService.java:52)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.alibaba.nacos.api.config.ConfigFactory.createConfigService(ConfigFactory.java:41)
... 25 more
Caused by: java.lang.ClassNotFoundException: org.slf4j.Logger
at java.net.URLClassLoader.findClass(URLClassLoader.java:387)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 29 more
看起来是Slf4j缺失(注意这里是添加slf4j-nop),尝试添加
<dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-nop</artifactId> <version>2.0.7</version> </dependency>
加完之后尝试启动dubbo server
C:\Users\chang\.jdks\corretto-1.8.0_362\bin\java.exe -javaagent:D:\软件安装包\ideaIU-2020.3.4.win\lib\idea_rt.jar=56964:D:\软件安装包\ideaIU-2020.3.4.win\bin -Dfile.encoding=UTF-8 -classpath C:\Users\chang\.jdks\corretto-1.8.0_362\jre\lib\charsets.jar;C:\Users\chang\.jdks\corretto-1.8.0_362\jre\lib\ext\access-bridge-64.jar;C:\Users\chang\.jdks\corretto-1.8.0_362\jre\lib\ext\cldrdata.jar;C:\Users\chang\.jdks\corretto-1.8.0_362\jre\lib\ext\dnsns.jar;C:\Users\chang\.jdks\corretto-1.8.0_362\jre\lib\ext\jaccess.jar;C:\Users\chang\.jdks\corretto-1.8.0_362\jre\lib\ext\jfxrt.jar;C:\Users\chang\.jdks\corretto-1.8.0_362\jre\lib\ext\localedata.jar;C:\Users\chang\.jdks\corretto-1.8.0_362\jre\lib\ext\nashorn.jar;C:\Users\chang\.jdks\corretto-1.8.0_362\jre\lib\ext\sunec.jar;C:\Users\chang\.jdks\corretto-1.8.0_362\jre\lib\ext\sunjce_provider.jar;C:\Users\chang\.jdks\corretto-1.8.0_362\jre\lib\ext\sunmscapi.jar;C:\Users\chang\.jdks\corretto-1.8.0_362\jre\lib\ext\sunpkcs11.jar;C:\Users\chang\.jdks\corretto-1.8.0_362\jre\lib\ext\zipfs.jar;C:\Users\chang\.jdks\corretto-1.8.0_362\jre\lib\jce.jar;C:\Users\chang\.jdks\corretto-1.8.0_362\jre\lib\jfr.jar;C:\Users\chang\.jdks\corretto-1.8.0_362\jre\lib\jfxswt.jar;C:\Users\chang\.jdks\corretto-1.8.0_362\jre\lib\jsse.jar;C:\Users\chang\.jdks\corretto-1.8.0_362\jre\lib\management-agent.jar;C:\Users\chang\.jdks\corretto-1.8.0_362\jre\lib\resources.jar;C:\Users\chang\.jdks\corretto-1.8.0_362\jre\lib\rt.jar;C:\Users\chang\IdeaProjects\dubbo-server-demo\dubbo-server\target\classes;C:\Users\chang\IdeaProjects\dubbo-server-demo\dubbo-server-api\target\classes;D:\study\repository\org\apache\dubbo\dubbo\2.7.8\dubbo-2.7.8.jar;D:\study\repository\org\springframework\spring-context\4.3.16.RELEASE\spring-context-4.3.16.RELEASE.jar;D:\study\repository\org\springframework\spring-aop\4.3.16.RELEASE\spring-aop-4.3.16.RELEASE.jar;D:\study\repository\org\springframework\spring-expression\4.3.16.RELEASE\spring-expression-4.3.16.RELEASE.jar;D:\study\repository\com\alibaba\spring\spring-context-support\1.0.8\spring-context-support-1.0.8.jar;D:\study\repository\org\javassist\javassist\3.20.0-GA\javassist-3.20.0-GA.jar;D:\study\repository\io\netty\netty-all\4.1.25.Final\netty-all-4.1.25.Final.jar;D:\study\repository\com\google\code\gson\gson\2.8.5\gson-2.8.5.jar;D:\study\repository\org\yaml\snakeyaml\1.20\snakeyaml-1.20.jar;D:\study\repository\com\alibaba\fastjson\1.2.70\fastjson-1.2.70.jar;D:\study\repository\org\springframework\spring-beans\5.3.12\spring-beans-5.3.12.jar;D:\study\repository\org\springframework\spring-core\5.3.12\spring-core-5.3.12.jar;D:\study\repository\org\springframework\spring-jcl\5.3.12\spring-jcl-5.3.12.jar;D:\study\repository\com\alibaba\nacos\nacos-client\2.0.4\nacos-client-2.0.4.jar;D:\study\repository\commons-codec\commons-codec\1.11\commons-codec-1.11.jar;D:\study\repository\com\fasterxml\jackson\core\jackson-core\2.12.2\jackson-core-2.12.2.jar;D:\study\repository\com\fasterxml\jackson\core\jackson-databind\2.12.2\jackson-databind-2.12.2.jar;D:\study\repository\com\fasterxml\jackson\core\jackson-annotations\2.12.2\jackson-annotations-2.12.2.jar;D:\study\repository\org\apache\httpcomponents\httpasyncclient\4.1.3\httpasyncclient-4.1.3.jar;D:\study\repository\org\apache\httpcomponents\httpcore\4.4.6\httpcore-4.4.6.jar;D:\study\repository\org\apache\httpcomponents\httpcore-nio\4.4.6\httpcore-nio-4.4.6.jar;D:\study\repository\org\apache\httpcomponents\httpclient\4.5.3\httpclient-4.5.3.jar;D:\study\repository\commons-logging\commons-logging\1.2\commons-logging-1.2.jar;D:\study\repository\org\reflections\reflections\0.9.11\reflections-0.9.11.jar;D:\study\repository\com\google\guava\guava\20.0\guava-20.0.jar;D:\study\repository\io\prometheus\simpleclient\0.5.0\simpleclient-0.5.0.jar;D:\study\repository\org\slf4j\slf4j-nop\2.0.7\slf4j-nop-2.0.7.jar;D:\study\repository\org\slf4j\slf4j-api\2.0.7\slf4j-api-2.0.7.jar org.cyf.App
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang3/StringUtils
at org.apache.dubbo.registry.nacos.NacosRegistry.appendIfPresent(NacosRegistry.java:327)
at org.apache.dubbo.registry.nacos.NacosRegistry.getLegacySubscribedServiceName(NacosRegistry.java:319)
at org.apache.dubbo.registry.nacos.NacosRegistry.getServiceNames0(NacosRegistry.java:280)
at org.apache.dubbo.registry.nacos.NacosRegistry.getServiceNames(NacosRegistry.java:267)
at org.apache.dubbo.registry.nacos.NacosRegistry.doSubscribe(NacosRegistry.java:178)
at org.apache.dubbo.registry.support.FailbackRegistry.subscribe(FailbackRegistry.java:333)
at org.apache.dubbo.registry.ListenerRegistryWrapper.subscribe(ListenerRegistryWrapper.java:105)
at org.apache.dubbo.registry.integration.RegistryProtocol.export(RegistryProtocol.java:225)
at org.apache.dubbo.rpc.protocol.ProtocolListenerWrapper.export(ProtocolListenerWrapper.java:62)
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper.export(ProtocolFilterWrapper.java:153)
at org.apache.dubbo.qos.protocol.QosProtocolWrapper.export(QosProtocolWrapper.java:64)
at org.apache.dubbo.rpc.Protocol$Adaptive.export(Protocol$Adaptive.java)
at org.apache.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:492)
at org.apache.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:325)
at org.apache.dubbo.config.ServiceConfig.doExport(ServiceConfig.java:300)
at org.apache.dubbo.config.ServiceConfig.export(ServiceConfig.java:206)
at org.apache.dubbo.config.bootstrap.DubboBootstrap.lambda$exportServices$15(DubboBootstrap.java:1103)
at java.util.HashMap$Values.forEach(HashMap.java:982)
at org.apache.dubbo.config.bootstrap.DubboBootstrap.exportServices(DubboBootstrap.java:1090)
at org.apache.dubbo.config.bootstrap.DubboBootstrap.start(DubboBootstrap.java:901)
at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onContextRefreshedEvent(DubboBootstrapApplicationListener.java:59)
at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onApplicationContextEvent(DubboBootstrapApplicationListener.java:52)
at org.apache.dubbo.config.spring.context.OneTimeExecutionApplicationContextEventListener.onApplicationEvent(OneTimeExecutionApplicationContextEventListener.java:40)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:883)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)
at org.apache.dubbo.container.spring.SpringContainer.start(SpringContainer.java:50)
at org.apache.dubbo.container.Main.main(Main.java:90)
at org.cyf.App.main(App.java:14)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang3.StringUtils
at java.net.URLClassLoader.findClass(URLClassLoader.java:387)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 33 moreProcess finished with exit code 1
网上各种让导入 commons-long3.3.1 jar包的,连标点符号都一样,你们真的试过吗??
最后我把nacos的版本调低了解决 <dependency> <groupId>com.alibaba.nacos</groupId> <artifactId>nacos-client</artifactId> <version>1.4.4</version> </dependency>
[2023-08-09 13:14:36] Dubbo service server started!
Nacos也注册成功