tinmegali
6/28/2019 - 9:18 PM

Spring / Eureka / Jhipster-Registry : Getting micro-services URLs

More information on Eureka documentation.

Get EurekaClient instance and call the the needed information using the micro-service name.

    @Qualifier("eurekaClient")
    @Autowired
    private EurekaClient eurekaClient;

    public String courseUrl() {
        // the micro-service name is 'course' and the service is secured
        InstanceInfo info = eurekaClient.getNextServerFromEureka("course", true);
        return info.getHomePageUrl();
    }