Hello I tried launching a Feign + SpringCloud Demo with Nacos as the configuration center,but Nacos started abnormally, please help me to check the problem, thank you very much!!!
MY Exception Message: java.lang.IllegalStateException: failed to req API:/nacos/v1/ns/instance after all servers([127.0.0.1:8848]) tried: failed to req API:127.0.0.1:8848/nacos/v1/ns/instance. code:500 msg: java.net.ConnectException: Connection refused (Connection refused) at com.alibaba.nacos.client.naming.net.NamingProxy.reqAPI(NamingProxy.java:467) ~[nacos-client-1.1.4.jar:na] at com.alibaba.nacos.client.naming.net.NamingProxy.reqAPI(NamingProxy.java:389) ~[nacos-client-1.1.4.jar:na] at com.alibaba.nacos.client.naming.net.NamingProxy.registerService(NamingProxy.java:191) ~[nacos-client-1.1.4.jar:na] at com.alibaba.nacos.client.naming.NacosNamingService.registerInstance(NacosNamingService.java:207) ~[nacos-client-1.1.4.jar:na] at com.alibaba.cloud.nacos.registry.NacosServiceRegistry.register(NacosServiceRegistry.java:64) ~[spring-cloud-alibaba-nacos-discovery-2.2.0.RELEASE.jar:2.2.0.RELEASE] at org.springframework.cloud.client.serviceregistry.AbstractAutoServiceRegistration.register(AbstractAutoServiceRegistration.java:239) ~[spring-cloud-commons-2.2.1.RELEASE.jar:2.2.1.RELEASE]
My application.yaml
spring: application: name: demo-provider cloud: nacos: discovery: server-addr: 127.0.0.1:8848 server: port: ${random.int[10000,19999]}
My code:
@RestController public class ProviderController {
private Logger logger = LoggerFactory.getLogger(ProviderController.class); @Value("${server.port}") private Integer serverPort; @GetMapping("/echo") public String echo(String name) throws InterruptedException { // 模拟执行 100ms 时长。方便后续我们测试请求超时 Thread.sleep(100L); // 记录被调用的日志 logger.info("[echo][被调用啦 name({})]", name); return serverPort + "-provider:" + name; }
}