Last active
June 10, 2018 17:10
-
-
Save OmarElgabry/1eaba7204b19ecc4e91b7c13411936da to your computer and use it in GitHub Desktop.
Eureka Gallery Service Class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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