Service discovery: Eureka Serverhow to include Eureka servers
to include the Eureka server in your project, use org.springframework.cloud
spring-cloud-starter-eureka-server
the initiator of the group and artifact IDs. for More information about using the current Spring Cloud Publishing list settings to build your system, see The Spring Cloud project page .
How to run the Eureka server
Example Eureka Server;
@SpringBootApplication@EnableEurekaServerpublic class Application { public static void main(String[] args) { new SpringApplicationBuilder(Application.class).web(true).run(args); }}
Create Springboot project Build Eureka
In. In the YML configuration file
Server
port:8761
Eureka
Client
Register-with-eureka:false
Fetch-registry:false
Server
Wait-time-in-ms-when-sync-empty:5
Server
port:8761
Eureka
Client
Register-with-eureka:false
Fetch-registry:false
Server
Wait-time-in-ms-when-sync-empty:5
The Eureka address in config points to the project address
Pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
<relativePath/> <!--lookup parent from repository to
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Finchley.SR1</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupid>org.springframework.boot</groupid>
<artifactid>spring-boot-starter-actuator</artifactid>
</dependency>
<dependency>
<groupid>org.springframework.cloud</groupid>
<artifactId> Spring-cloud-starter-netflix-eureka-server</artifactid>
</dependency>
<dependency>
<groupid>org.springframework.boot</groupid>
<artifactId> Spring-boot-devtools</artifactid>
<scope>runtime</scope>
</dependency>
< Dependency>
<groupid>org.projectlombok</groupid>
<artifactid>lombok</artifactid
<optional>true</optional>
</dependency>
<dependency>
<groupId> Org.springframework.boot</groupid>
<artifactid>spring-boot-starter-test</artifactid>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Configure the heartbeat before you can directly access the project address to detect the project
Spring Cloud's Eureka configuration