: Create Project Engineering
New Project
Choose Gradle Here
Direct Next
Continue Next
Finally click Finish
Second: Create Eureka Service Center
Select the project that you created in the first step, and right-click the new--->module
Select Spring Initializr, then next
Enter group, Artifact, and select Gradle Project, then next
Select Eureka Server, then click Next
Enter module name and finish
I've got a couple of hooks in here, and then OK.
Three: Code
The code is simple, just need to add a @enableeurekaserver annotation on the startup application class of the Springboot project, as follows:
1 PackageCom.cloud.microservice.demo.eurekaserver;2 3 Importorg.springframework.boot.SpringApplication;4 Importorg.springframework.boot.autoconfigure.SpringBootApplication;5 ImportOrg.springframework.cloud.netflix.eureka.server.EnableEurekaServer;6 7 @EnableEurekaServer8 @SpringBootApplication9 Public classeurekaserverapplication {Ten One Public Static voidMain (string[] args) { ASpringapplication.run (eurekaserverapplication.class, args); - } -}
Eureka Server configuration file Appication.yml:
1 Server:2port:90903 4 Eureka:5 instance:6 Hostname:localhost7 Client:8Registerwitheureka:false9Fetchregistry:falseTen serviceurl: OneDefaultzone:http://${eureka.instance.hostname}:${server.port}/eureka/
Start the project, open the browser access: http://localhost:9090, the interface is as follows:
Springcloud Series Research---Eureka service discovery