Spring Cloud's Eureka configuration

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.