Eureka Server Spring Boot MicroService
November 14, 2019 | Spring boot complete tutorial with example | No Comments
Eureka Server is used to monitor all the application. With the help of Eureka Server we don’t need to worry about information like which application running on which port and how many instances of application are running, all this are take cares by Eureka Server.So to Create a Eureka Server we have to follow below steps:
- Add required dependency in you pom.xml file
- Enable Your main class as a Eureka Server using @EnableEurekaServer annotation.
- Define applicationName and portNo in application.properties file.
- By Default Eureka act as a client but now we want this application to work as Eureka Server so we make Eureka registry as false in application.properties file.
1- Add the Eureka Server dependency in your pom.xml file.
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> </dependency>
2- Enable Eureka Server by using @EnableEurekaServer annotation in your main class.
@EnableEurekaServer @SpringBootApplication public class EurekaServerApplication { public static void main(String[] args) { SpringApplication.run(EurekaServerApplication.class, args); } }
3- By Default Eureka Server application running as a client so if we have want to act this application as a server then we have to add below properties in application.properties file
spring.application.name=netflix-eureka-server server.port=8761 eureka.client.register-with-eureka=false eureka.client.fetch-registry=false
In above application.properties file
server.port define the port on which Eureka Server running in our case it is running on 8761 port so to access your eureka server just hit below URL in your browser.
