Spring cloud of eureka build

This article for everyone to build a eureka project, the main display features found in its services:

First, add a pom-dependent, you can select the relevant depend directly If you use the idea to create a maven project, where the use of hands to build eclipse:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.1.1.RELEASE</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>
	<groupId>com.zsy.cloud</groupId>
	<artifactId>cloud-eureka</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>jar</packaging>
	<name>zsy-eureka</name>
	
	<properties>
		<java.version>1.8</java.version>
		<spring-cloud.version>Greenwich.M3</spring-cloud.version>
	</properties>
	
	<dependencies>
		
		<!--SpringCloud eureka-server -->
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
		</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>
	
	<repositories>
		<repository>
			<id>spring-milestones</id>
			<name>Spring Milestones</name>
			<url>https://repo.spring.io/milestone</url>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
		</repository>
	</repositories>
	
	


</project>

 

yml file:

server:
  port: 8081  #服务端口
###服务名称(服务注册到eureka名称,如果需要注册自己,必须声明服务名称)
spring:
  application:
    name: eureka-server

eureka:
  instance:
    ###注册到eurekaip地址
    hostname: 127.0.0.1
  client:
    serviceUrl:
      # 注册中心服务接口,别的服务需要注册时使用这个接口即可(最好一个斜杠后面的服务名称必须是eureka)
      defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka
    ###因为自己是注册中心,不需要自己注册自己
    register-with-eureka: false
    ###因为自己是注册中心,不需要检索服务
    fetch-registry: false
  server:
    # 测试时关闭自我保护机制,保证不可用服务及时踢出
    enable-self-preservation: false
    eviction-interval-timer-in-ms: 2000

Start categories:

package com.zsy.cloud.eureka;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;

@SpringBootApplication
@EnableEurekaServer
public class EurekaServerApp {

	public static void main(String[] args) {
		SpringApplication.run(EurekaServerApp.class, args);
	}
}

 

eureka management page:

 

Page showed no registration service, the next chapter to write a client to register.

Guess you like

Origin blog.csdn.net/syilt/article/details/91470961