Perfect solution: java.net.UnknownHostException: XXX error reported in nacos

Solved: java.net.UnknownHostException reported in nacos

Table of contents

1.Problem description

2.Solution process


1.Problem description

The IP address of the virtual machine is 192.168.10.100. Nacos is successfully installed in docker and can be accessed normally. Then the service can be registered and discovered normally in nacos, but it cannot be called. When called, it says unknownhost exception. The specific error is as shown below. :

2.Solution process

My version of SpringCloud is 2021.0.4, the corresponding version of springboot is 2.6.7, and nacos uses 2.2.0. Because Netflix is ​​no longer used in versions after Spring Cloud 2020.0.1.0, we do not use Ribbon to achieve load balancing. Therefore, you need to add the following dependencies on the consumer server

<!-- 升级spring cloud之后,Nacos消费者服务依赖该组件 -->
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-loadbalancer</artifactId>
</dependency>

I record the problems I encountered at work and the process of solving them, and I hope it can help everyone!

Guess you like

Origin blog.csdn.net/white0718/article/details/131788774