current position:Home>Nacos consumer uses resttemplate to report error 500, wrong service name,

Nacos consumer uses resttemplate to report error 500, wrong service name,

2022-01-27 00:29:11 CSDN Q & A

I thought it was simple , Just run through the official documents ,nacos,8848, No play, no problem , Server side provider,9001 9002 No problem with both providers , The visit is normal , Then the consumer side , Use configuration,loadbalanced,bean, annotation , Inject rest template, And then call getforobject,uri yes ,9001 Of spring application name, And it's also 9002 Of , stay nacos The service also has , Look at the code n Many times 、 There is absolutely no mistake , And then visit consumer Address , Wrong address 500, There is one unknown host, Then is cloud-nacos-server/nacos/echo/str, But the service name is right , The official documents are written like this , Is there something wrong , I hope the boss has a way to tell , thank you ,




Refer to the answer 1:

Inject a... Into the container yourself restTemplate , add LoadBalanced,
When you use it ,
@Autowired
@LoadBalanced
private RestTemplate restTemplate;
In this way, load balancing , Otherwise, write honestly ip




Refer to the answer 2:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/01/202201270029094726.html

Random recommended