首页 > 解决方案 > 如何将尤里卡客户端指向部署在不同 IP 地址中的尤里卡服务器,而不是在本地主机中

问题描述

我有一个问题,我有一个 Spring Boot eureka 服务器在 URL http://192.168.3.177:8761/eureka的服务器上运行。现在我有 eureka 客户端(一些服务)在其他 IP 地址上运行,即192.168.1.123。但是现在的问题是当 eureka 客户端启动它时,它将 eureka 服务器 IP 作为localhost:8761/eureka并给出连接被拒绝异常。如果我在运行 eureka 服务器的同一台服务器上运行 eureka 客户端应用程序,它会按预期工作。

以下是我在 application.properties 中的 eureka 客户端配置

eureka.client.service-url.default-zone=http://192.168.3.174:8761/eureka

我的尤里卡客户端应用程序

@SpringBootApplication
@EnableFeignClients("com.samsan.currencyconversionservice")
@EnableDiscoveryClient
public class CurrencyConversionServiceApplication {

    public static void main(String[] args) {
        SpringApplication.run(CurrencyConversionServiceApplication.class, args);
    }

}

我正在使用功能区连接到尤里卡服务器以获取服务

@Component
@FeignClient(name="currency-exchange-service")
@RibbonClient(name="currency-exchange-service")
public interface CurrencyExchangeService {

    @GetMapping("/currency-exchange/from/{from}/to/{to}")
    public CurrencyConversionBean getExchangeValue(@PathVariable("from") String from, @PathVariable("to") String to);

}

请帮我解决这个问题?

标签: javaspringspring-bootnetflix-eureka

解决方案


推荐阅读