Installing Eureka Server

First, we're going to create the server project to initialize the Eureka Server by adding the Spring Cloud dependency, as follows:

<dependency> 
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
<version>1.4.0.RELEASE</version>
</dependency>
At the time of writing, the latest available version of Spring Cloud services is 1.4.0.RELEASE.

Within the code of a Spring Boot application, we are going to enable the Eureka Server related configuration by adding the @EnableEurekaServer annotation:

@SpringBootApplication
@EnableEurekaServer
public class EurekaWeatherServiceServer {
public static void main(String... args) {
SpringApplication.run(EurekaWeatherServiceServer.class);
}
}

The application.properties file for configuring the Eureka Server is as shown in the following code. server.port defines the port that will be used by the server. 8761 is the most commonly used port number used for the server; if it's not provided, the Server will allocate 8080 by default. With eureka.client.register-with-eureka, we are telling the Eureka built-in client not to register itself since our application should be acting as a server:

server.port=8761
eureka.client.register-with-eureka=false

After invoking the main method on the EurekaWeatherServiceServer class, and then requesting http://localhost:8761, you should see the dashboard of Eureka Server, as follows:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.227.134.133