search

Home  >  Q&A  >  body text

java - spring cloud eureka,ribbon restTemplate 访问问题


入图,在eureka中心已经有了这个服务者,服务者的配置信息如下

但是通过以下代码:


访问时一直提示:
I/O error on GET request for "http://client": Connection refused: connect; nested exception is java.net.ConnectException: Connection refused: connect

请问该怎么把,就是好像没办法用实例名访问?

谢谢各位的回答,已经解决了!是我自己的问题。。

黄舟黄舟2888 days ago663

reply all(4)I'll reply

  • 天蓬老师

    天蓬老师2017-04-18 10:35:22

    This is what the official document says

    @Autowired
    private EurekaClient discoveryClient;
    
    public String serviceUrl() {
        InstanceInfo instance = discoveryClient.getNextServerFromEureka("STORES", false);
        return instance.getHomePageUrl();
    }
    

    The access methods are different
    Please refer to http://cloud.spring.io/spring...

    reply
    0
  • 高洛峰

    高洛峰2017-04-18 10:35:22

    help me....Everyone

    reply
    0
  • PHPz

    PHPz2017-04-18 10:35:22

    reply
    0
  • ringa_lee

    ringa_lee2017-04-18 10:35:22

    Have you configured this@EnableDiscoveryClientannotation?

    reply
    0
  • Cancelreply