Skip to content

Instantly share code, notes, and snippets.

@ilaborie
Created May 15, 2016 10:24
Show Gist options
  • Save ilaborie/e8108522f5c726cd835fa2de0925b3d0 to your computer and use it in GitHub Desktop.
Save ilaborie/e8108522f5c726cd835fa2de0925b3d0 to your computer and use it in GitHub Desktop.

How to Micro-services with Springboot with Config Server, Eureka, Zuul, Ribbon

Config server

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-config-server</artifactId>
</dependency>

And add @EnableConfigServer on application To use the native file configuration instead of git, set the application.properties with

server.port=8888
spring.profiles.active=native
spring.cloud.config.server.native.searchLocations=classpath:/XXX

debug=true
info.id=${spring.application.name}

All config client

Client spring boot application should remove the application.properties and create a bootstrap.properties

spring.application.name=my-name
spring.cloud.config.uri=http://localhost:8888

And add @EnableDiscoveryClient on application

Service registry with Eureka

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-eureka-server</artifactId>
</dependency>

And add @EnableEurekaServer on application

Reverse proxy with Zuul, Ribbon

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-zuul</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>

And add @EnableZuulProxy on application

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment