Nacos工程启动报错java.lang.IllegalStateException: failed to req API:/nacos/v1/ns/instance after all server

Nacos工程启动报错java.lang.IllegalStateException: failed to req API:/nacos/v1/ns/instance after all servers([127.0.0.1:8848]) tried

一个很简单的nacos工程,虽然启动时报错,但可以正常注册到nacos注册中心,所以一开始没怎么管它,但是作为有强迫症的人来说怎么能接受有错呢。。

Thu Jun 11 12:05:24 GMT+08:00 2020 sun.misc.Launcher$AppClassLoader@18b4aac2 JM.Log:INFO Init JM logger with Slf4jLoggerFactory success, sun.misc.Launcher$AppClassLoader@18b4aac2
Thu Jun 11 12:05:24 GMT+08:00 2020 sun.misc.Launcher$AppClassLoader@18b4aac2 JM.Log:INFO Log root path: C:\Users\74757\logs\
Thu Jun 11 12:05:24 GMT+08:00 2020 sun.misc.Launcher$AppClassLoader@18b4aac2 JM.Log:INFO Set nacos log path: C:\Users\74757\logs\nacos
2020-06-11 12:05:24.394 ERROR 3224 --- [           main] o.s.c.a.n.registry.NacosServiceRegistry  : nacos registry, easystudy-videoservice register failed...NacosRegistration{nacosDiscoveryProperties=NacosDiscoveryProperties{serverAddr='127.0.0.1:8848', endpoint='', namespace='', logName='', service='easystudy-videoservice', weight=1.0, clusterName='DEFAULT', metadata={}, registerEnabled=true, ip='192.168.43.49', networkInterface='', port=8002, secure=false, accessKey='', secretKey=''}},

java.lang.IllegalStateException: failed to req API:/nacos/v1/ns/instance after all servers([127.0.0.1:8848]) tried
	at com.alibaba.nacos.client.naming.net.NamingProxy.reqAPI(NamingProxy.java:339) ~[nacos-client-0.3.0.jar:na]
	at com.alibaba.nacos.client.naming.net.NamingProxy.reqAPI(NamingProxy.java:272) ~[nacos-client-0.3.0.jar:na]
	at com.alibaba.nacos.client.naming.net.NamingProxy.registerService(NamingProxy.java:171) ~[nacos-client-0.3.0.jar:na]
	at com.alibaba.nacos.client.naming.NacosNamingService.registerInstance(NacosNamingService.java:161) ~[nacos-client-0.3.0.jar:na]
	at org.springframework.cloud.alibaba.nacos.registry.NacosServiceRegistry.register(NacosServiceRegistry.java:58) [spring-cloud-alibaba-nacos-discovery-0.2.0.RELEASE.jar:0.2.0.RELEASE]
	at org.springframework.cloud.alibaba.nacos.registry.NacosServiceRegistry.register(NacosServiceRegistry.java:31) [spring-cloud-alibaba-nacos-discovery-0.2.0.RELEASE.jar:0.2.0.RELEASE]
	at org.springframework.cloud.client.serviceregistry.AbstractAutoServiceRegistration.register(AbstractAutoServiceRegistration.java:211) [spring-cloud-commons-2.0.2.RELEASE.jar:2.0.2.RELEASE]
	at org.springframework.cloud.alibaba.nacos.registry.NacosAutoServiceRegistration.register(NacosAutoServiceRegistration.java:75) [spring-cloud-alibaba-nacos-discovery-0.2.0.RELEASE.jar:0.2.0.RELEASE]
	at org.springframework.cloud.client.serviceregistry.AbstractAutoServiceRegistration.start(AbstractAutoServiceRegistration.java:110) [spring-cloud-commons-2.0.2.RELEASE.jar:2.0.2.RELEASE]
	at org.springframework.cloud.client.serviceregistry.AbstractAutoServiceRegistration.bind(AbstractAutoServiceRegistration.java:74) [spring-cloud-commons-2.0.2.RELEASE.jar:2.0.2.RELEASE]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_201]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_201]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_201]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_201]
	at org.springframework.context.event.ApplicationListenerMethodAdapter.doInvoke(ApplicationListenerMethodAdapter.java:261) [spring-context-5.0.11.RELEASE.jar:5.0.11.RELEASE]
	at org.springframework.context.event.ApplicationListenerMethodAdapter.processEvent(ApplicationListenerMethodAdapter.java:180) [spring-context-5.0.11.RELEASE.jar:5.0.11.RELEASE]
	at org.springframework.context.event.ApplicationListenerMethodAdapter.onApplicationEvent(ApplicationListenerMethodAdapter.java:142) [spring-context-5.0.11.RELEASE.jar:5.0.11.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) [spring-context-5.0.11.RELEASE.jar:5.0.11.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) [spring-context-5.0.11.RELEASE.jar:5.0.11.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) [spring-context-5.0.11.RELEASE.jar:5.0.11.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:400) [spring-context-5.0.11.RELEASE.jar:5.0.11.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:354) [spring-context-5.0.11.RELEASE.jar:5.0.11.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:166) [spring-boot-2.0.7.RELEASE.jar:2.0.7.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551) [spring-context-5.0.11.RELEASE.jar:5.0.11.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) [spring-boot-2.0.7.RELEASE.jar:2.0.7.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) [spring-boot-2.0.7.RELEASE.jar:2.0.7.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:386) [spring-boot-2.0.7.RELEASE.jar:2.0.7.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) [spring-boot-2.0.7.RELEASE.jar:2.0.7.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1242) [spring-boot-2.0.7.RELEASE.jar:2.0.7.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1230) [spring-boot-2.0.7.RELEASE.jar:2.0.7.RELEASE]
	at com.online.edu.videoservice.VideoApplication.main(VideoApplication.java:18) [classes/:na]

2020-06-11 12:05:24.402  INFO 3224 --- [           main] c.o.edu.videoservice.VideoApplication    : Started VideoApplication in 8.903 seconds (JVM running for 10.635)

查阅了很多文章以及资料以后,终于在一篇博客中得到了问题的解决方案,最后将奉上文章的源地址。
最终解决方案
  空指针异常,好吧,新出的框架就是问题多。。搜索这个异常时,github上有人说是版本问题。最终发现是spring-cloud-starter-alibaba-nacos-discovery这个的版本影响的,上述报错用的是0.2.0.RELEASE这个版本,换成0.2.1.RELEASE就好了。。

  本文解决方案来自:http://zpycloud.com/archives/1438

你可能感兴趣的:(日常出错记录,后端)