SpringCloud : eureka-server

SpringCloud : eureka-server 註冊中心

建造步驟:
一、POM
(繼承了父項目Spring-Cloud-ForLearning中的一個依賴,父項目構造見博文:Spring-Cloud-ForLearning):

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-dependencies</artifactId>
    <version>Finchley.SR1</version>
    <type>pom</type>
    <scope>import</scope>
</dependency>
<?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">
    <parent>
        <artifactId>Spring-Cloud-ForLearning</artifactId>
        <groupId>com.wx</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>eureka-center</artifactId>
    <dependencies>
        <!--springboot 整合eureka服務端-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

二、啓動類加註解:@EnableEurekaServer
三、application.yml

server:
  port: 8100
eureka:
  instance:
    hostname: localhost
  client:
    service-url:
      defaultZone: http://${eureka.instance.hostname}:8100/eureka/
    ###是否將自己註冊到Eureka服務中,因爲該應用本身就是註冊中心,不需要再註冊自己(集羣的時候爲true)
    register-with-eureka: false
    ###是否從Eureka中獲取註冊信息,因爲自己爲註冊中心,不會在該應用中的檢索服務信息
    fetch-registry: false
  server:
    enable-self-preservation: false
spring:
  application:
    name: eureka-center-app

四、項目結構:

在這裏插入圖片描述
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章