nacos开启鉴权后,服务启动报错(解决方案)

java 复制代码
2023-07-19 16:29:10.381  INFO 28232 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Could not unregister MBean [com.github.tobato.fastdfs.conn:name=fdfsConnectionPool,type=FdfsConnectionPool] as said MBean is not registered (perhaps already unregistered by an external process)
2023-07-19 16:29:10.405 ERROR 28232 --- [           main] o.s.boot.SpringApplication               : Application run failed

java.lang.RuntimeException: ErrCode:500, ErrMsg:Request nacos server failed: 
	at org.apache.dubbo.common.function.ThrowableFunction.execute(ThrowableFunction.java:54) ~[dubbo-3.0.6.jar:3.0.6]
	at org.apache.dubbo.common.function.ThrowableFunction.execute(ThrowableFunction.java:69) ~[dubbo-3.0.6.jar:3.0.6]
	at org.apache.dubbo.registry.nacos.NacosServiceDiscovery.getInstances(NacosServiceDiscovery.java:103) ~[dubbo-3.0.6.jar:3.0.6]
	at org.apache.dubbo.registry.client.ServiceDiscoveryRegistry.subscribeURLs(ServiceDiscoveryRegistry.java:310) ~[dubbo-3.0.6.jar:3.0.6]
	at org.apache.dubbo.registry.client.ServiceDiscoveryRegistry.doSubscribe(ServiceDiscoveryRegistry.java:216) ~[dubbo-3.0.6.jar:3.0.6]
	at org.apache.dubbo.registry.client.ServiceDiscoveryRegistry.subscribe(ServiceDiscoveryRegistry.java:184) ~[dubbo-3.0.6.jar:3.0.6]
	at org.apache.dubbo.registry.ListenerRegistryWrapper.subscribe(ListenerRegistryWrapper.java:111) ~[dubbo-3.0.6.jar:3.0.6]
	at org.apache.dubbo.registry.integration.DynamicDirectory.subscribe(DynamicDirectory.java:180) ~[dubbo-3.0.6.jar:3.0.6]
	at org.apache.dubbo.registry.client.ServiceDiscoveryRegistryDirectory.subscribe(ServiceDiscoveryRegistryDirectory.java:107) ~[dubbo-3.0.6.jar:3.0.6]
	at org.apache.dubbo.registry.integration.RegistryProtocol.doCreateInvoker(RegistryProtocol.java:569) ~[dubbo-3.0.6.jar:3.0.6]
	at org.apache.dubbo.registry.integration.InterfaceCompatibleRegistryProtocol.getServiceDiscoveryInvoker(InterfaceCompatibleRegistryProtocol.java:65) ~[dubbo-3.0.6.jar:3.0.6]
	at org.apache.dubbo.registry.client.migration.MigrationInvoker.refreshServiceDiscoveryInvoker(MigrationInvoker.java:428) ~[dubbo-3.0.6.jar:3.0.6]
	at org.apache.dubbo.registry.client.migration.MigrationInvoker.migrateToForceApplicationInvoker(MigrationInvoker.java:205) ~[dubbo-3.0.6.jar:3.0.6]
	at org.apache.dubbo.registry.client.migration.MigrationRuleHandler.refreshInvoker(MigrationRuleHandler.java:76) ~[dubbo-3.0.6.jar:3.0.6]
	at org.apache.dubbo.registry.client.migration.MigrationRuleHandler.doMigrate(MigrationRuleHandler.java:57) ~[dubbo-3.0.6.jar:3.0.6]
	at org.apache.dubbo.registry.client.migration.MigrationRuleListener.onRefer(MigrationRuleListener.java:241) ~[dubbo-3.0.6.jar:3.0.6]
	at org.apache.dubbo.registry.integration.RegistryProtocol.interceptInvoker(RegistryProtocol.java:534) ~[dubbo-3.0.6.jar:3.0.6]
	at org.apache.dubbo.registry.integration.RegistryProtocol.doRefer(RegistryProtocol.java:504) ~[dubbo-3.0.6.jar:3.0.6]
	at org.apache.dubbo.registry.integration.RegistryProtocol.refer(RegistryProtocol.java:486) ~[dubbo-3.0.6.jar:3.0.6]
	at org.apache.dubbo.rpc.protocol.ProtocolListenerWrapper.refer(ProtocolListenerWrapper.java:74) ~[dubbo-3.0.6.jar:3.0.6]
	at org.apache.dubbo.qos.protocol.QosProtocolWrapper.refer(QosProtocolWrapper.java:83) ~[dubbo-3.0.6.jar:3.0.6]
	at org.apache.dubbo.rpc.cluster.filter.ProtocolFilterWrapper.refer(ProtocolFilterWrapper.java:71) ~[dubbo-3.0.6.jar:3.0.6]
	at org.apache.dubbo.rpc.protocol.ProtocolSerializationWrapper.refer(ProtocolSerializationWrapper.java:52) ~[dubbo-3.0.6.jar:3.0.6]
	at org.apache.dubbo.rpc.Protocol$Adaptive.refer(Protocol$Adaptive.java) ~[dubbo-3.0.6.jar:3.0.6]
	at org.apache.dubbo.config.ReferenceConfig.createInvokerForRemote(ReferenceConfig.java:493) ~[dubbo-3.0.6.jar:3.0.6]
	at org.apache.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:396) ~[dubbo-3.0.6.jar:3.0.6]
	at org.apache.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:279) ~[dubbo-3.0.6.jar:3.0.6]
	at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:219) ~[dubbo-3.0.6.jar:3.0.6]
	at org.apache.dubbo.config.utils.SimpleReferenceCache.get(SimpleReferenceCache.java:110) ~[dubbo-3.0.6.jar:3.0.6]
	at org.apache.dubbo.config.deploy.DefaultModuleDeployer.lambda$referServices$6(DefaultModuleDeployer.java:384) ~[dubbo-3.0.6.jar:3.0.6]
	at java.util.concurrent.ConcurrentHashMap$ValuesView.forEach(ConcurrentHashMap.java:4707) ~[na:1.8.0_292]
	at org.apache.dubbo.config.deploy.DefaultModuleDeployer.referServices(DefaultModuleDeployer.java:364) ~[dubbo-3.0.6.jar:3.0.6]
	at org.apache.dubbo.config.deploy.DefaultModuleDeployer.start(DefaultModuleDeployer.java:151) ~[dubbo-3.0.6.jar:3.0.6]
	at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onContextRefreshedEvent(DubboDeployApplicationListener.java:111) ~[dubbo-3.0.6.jar:3.0.6]
	at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onApplicationEvent(DubboDeployApplicationListener.java:100) ~[dubbo-3.0.6.jar:3.0.6]
	at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onApplicationEvent(DubboDeployApplicationListener.java:45) ~[dubbo-3.0.6.jar:3.0.6]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176) ~[spring-context-5.3.21.jar:5.3.21]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169) ~[spring-context-5.3.21.jar:5.3.21]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143) ~[spring-context-5.3.21.jar:5.3.21]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:421) ~[spring-context-5.3.21.jar:5.3.21]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:378) ~[spring-context-5.3.21.jar:5.3.21]
	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:938) ~[spring-context-5.3.21.jar:5.3.21]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586) ~[spring-context-5.3.21.jar:5.3.21]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-2.7.1.jar:2.7.1]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) [spring-boot-2.7.1.jar:2.7.1]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) [spring-boot-2.7.1.jar:2.7.1]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) [spring-boot-2.7.1.jar:2.7.1]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) [spring-boot-2.7.1.jar:2.7.1]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) [spring-boot-2.7.1.jar:2.7.1]
	at com.mr.fzw.CbApplication.main(CbApplication.java:35) [classes/:na]
Caused by: com.alibaba.nacos.api.exception.NacosException: Request nacos server failed: 
	at com.alibaba.nacos.client.naming.remote.gprc.NamingGrpcClientProxy.requestToServer(NamingGrpcClientProxy.java:279) ~[nacos-client-2.0.3.jar:na]
	at com.alibaba.nacos.client.naming.remote.gprc.NamingGrpcClientProxy.doSubscribe(NamingGrpcClientProxy.java:227) ~[nacos-client-2.0.3.jar:na]
	at com.alibaba.nacos.client.naming.remote.gprc.NamingGrpcClientProxy.subscribe(NamingGrpcClientProxy.java:212) ~[nacos-client-2.0.3.jar:na]
	at com.alibaba.nacos.client.naming.remote.NamingClientProxyDelegate.subscribe(NamingClientProxyDelegate.java:147) ~[nacos-client-2.0.3.jar:na]
	at com.alibaba.nacos.client.naming.NacosNamingService.selectInstances(NacosNamingService.java:290) ~[nacos-client-2.0.3.jar:na]
	at com.alibaba.nacos.client.naming.NacosNamingService.selectInstances(NacosNamingService.java:260) ~[nacos-client-2.0.3.jar:na]
	at com.alibaba.nacos.client.naming.NacosNamingService.selectInstances(NacosNamingService.java:248) ~[nacos-client-2.0.3.jar:na]
	at org.apache.dubbo.registry.nacos.NacosNamingServiceWrapper.selectInstances(NacosNamingServiceWrapper.java:80) ~[dubbo-3.0.6.jar:3.0.6]
	at org.apache.dubbo.registry.nacos.NacosServiceDiscovery.lambda$getInstances$4(NacosServiceDiscovery.java:104) ~[dubbo-3.0.6.jar:3.0.6]
	at org.apache.dubbo.common.function.ThrowableFunction.execute(ThrowableFunction.java:52) ~[dubbo-3.0.6.jar:3.0.6]
	... 49 common frames omitted
Caused by: com.alibaba.nacos.api.exception.NacosException: user not found!
	at com.alibaba.nacos.client.naming.remote.gprc.NamingGrpcClientProxy.requestToServer(NamingGrpcClientProxy.java:271) ~[nacos-client-2.0.3.jar:na]
	... 58 common frames omitted

2023-07-19 16:29:11.359  WARN 28232 --- [      Thread-11] c.a.n.common.http.HttpClientBeanHolder   : [HttpClientBeanHolder] Start destroying common HttpClient
2023-07-19 16:29:11.359  WARN 28232 --- [      Thread-17] c.a.nacos.common.notify.NotifyCenter     : [NotifyCenter] Start destroying Publisher
2023-07-19 16:29:11.359  WARN 28232 --- [      Thread-17] c.a.nacos.common.notify.NotifyCenter     : [NotifyCenter] Destruction of the end
Disconnected from the target VM, address: '127.0.0.1:65206', transport: 'socket'

采用这种方式:

java 复制代码
dubbo:
  registry:
     address: nacos://localhost:8848?username=${username}&password=${password}
相关推荐
BBB努力学习程序设计12 分钟前
Java方法详解:提升代码复用性与可读性的利器
java
BBB努力学习程序设计12 分钟前
Java运算符完全指南:让代码学会“计算”和“判断”
java
用户84913717547161 小时前
ThreadLocal 源码深度解析:JDK 设计者的“妥协”与“智慧”
java·后端
用户0304805912631 小时前
# 【Maven避坑】源码去哪了?一文看懂 Maven 工程与打包后的目录映射关系
java·后端
v***55341 小时前
springboot使用logback自定义日志
java·spring boot·logback
qq_336313931 小时前
java基础-集合进阶
java·开发语言·windows
稚辉君.MCA_P8_Java1 小时前
Gemini永久会员 归并排序(Merge Sort) 基于分治思想(Divide and Conquer)的高效排序算法
java·linux·算法·spring·排序算法
q***18841 小时前
Spring Boot中的404错误:原因、影响及处理策略
java·spring boot·后端
222you1 小时前
MybatisPlus常用注解
java·开发语言·spring
汤姆Tom1 小时前
前端转战后端:JavaScript 与 Java 对照学习指南 (第一篇 - 深度进阶版)
java·javascript