Skip to content

Instantly share code, notes, and snippets.

@OmarElgabry
Last active June 10, 2018 17:10
Show Gist options
  • Select an option

  • Save OmarElgabry/1eaba7204b19ecc4e91b7c13411936da to your computer and use it in GitHub Desktop.

Select an option

Save OmarElgabry/1eaba7204b19ecc4e91b7c13411936da to your computer and use it in GitHub Desktop.
Eureka Gallery Service Class
package com.eureka.gallery;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
@SpringBootApplication
@EnableEurekaClient // Enable eureka client.
public class SpringEurekaGalleryApp {
public static void main(String[] args) {
SpringApplication.run(SpringEurekaGalleryApp.class, args);
}
}
@Configuration
class RestTemplateConfig {
// Create a bean for restTemplate to call services
@Bean
@LoadBalanced // Load balance between service instances running at different ports.
public RestTemplate restTemplate() {
return new RestTemplate();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment