Simplest Spring-Cloud Tutorial in 2018 | (1) Build a Eureka Server
Thanks to Spring Initializer project, we would be able to create SpringCloud with Spring Boot 2.0 projects with just few simple steps.
//definition and functionalities of Spring Cloud. For more details of the functionaries and implementation, please go through the official tutorial.
No need too many words, let’s have the project started.
Step 1. Create Server and Service Registration Centre
(1) Create Eureka Server project
The simplest way is to access start.spring.io and select the options like the screenshot below:
(2) Declare a Service Registration Centre
The only thing you need to do is just adding the annotation “@EnableEurekaServer” over the main entry class EurekaServerApplication(project path/src/main/java/ca/zhengyang/eurekaServer/EurekaServerApplication.java), just like the screenshot below:
(3) Add Eureka Server Configuration file, application.yml
Eureka Server is a eureka client as well by default, but we can disable it by adding configuration “registerWithEureka: false”
Create a file named as “application.yml” in the resources directory with the content:
server: port: 8761eureka: instance: hostname: localhost client: registerWithEureka: false fetchRegistry: false serviceUrl: defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
(4) Run your project! Eureka Server provides a management UI that can be seen at localhost:8761. See what magic comes to you! yeah! Happy Dance!
So now my friend, you already had a Eureka Server for Spring Cloud built successful, let’s move on to the next step, Create a Eureka Client.
Author: River (Zheng Yang) @ www.zhengyang.ca
All code is available on Github
Happy to hear any suggestion or insight from you guys, and don’t forget to give me a star! :)