Eclipseの実行時設定SpringCloud(ホクストン+ 2.2.4)+マイクロサービスフレームワークは、ユーレカ、ユーレカServerの高可用性クラスタを構築します

springcloudはspringboot建物に基づいて、マイクロサービスアーキテクチャのマスターである、優れた成分の一連の統合されました。
ここに画像を挿入説明
中国のドキュメントします。https://springcloud.cc/
公式ドキュメントします。http://projects.spring.io/spring-cloud/#quick-start

ビルド環境

春のブートバージョンが一致し、春の雲のバージョンとの関係を忘れないようにしてくださいます。https://spring.io/projects/spring-cloud

ソフトウェア
春の雲 Hoxton.RELEASE
春ブーツ 2.2.4.RELEASE
JDK 1.8
Mavenの 3.6

まず、レジストリを作成します

ここに画像を挿入説明
春クラウドの基本的なアプリケーション・パッケージを追加するためにPOMファイルの準備

<?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">
  <!-- 模型版本。maven2.0必须是这样写,现在是maven2唯一支持的版本 -->
  <modelVersion>4.0.0</modelVersion>
  <!-- 项目的的唯一标识符,并且配置时生成的路径也是由此生成,maven会将该项目打成的jar包放本地路径:/com/springcloud --> 
  <groupId>com.springcloud</groupId>
  <!-- 构件的标识符,它和group ID一起唯一标识一个构件,一个groupId下面可能多个项目,就是靠artifactId来区分的。
  Maven为项目产生的构件包括:JARs,源码,二进制发布和WARs等 -->
  <artifactId>springcloud-root</artifactId>
  <!-- 项目当前版本号,格式为:主版本.次版本.增量版本-限定版本号 -->
  <version>0.0.1-SNAPSHOT</version>
  <!-- 项目产生的构件类型,如pom,jar, maven-plugin, ejb, war, ear, rar, par,默认为jar -->
  <packaging>pom</packaging>
  <!-- 项目的名称, Maven产生的文档用 --> 
  <name>spring-cloud</name>
  <!-- 项目主页的URL, Maven产生的文档用 -->
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  
  <!-- 父项目的坐标。如果项目中没有规定某个元素的值,那么父项目中的对应值即为项目的默认值。坐标包括group ID,artifact ID和 version。 --> 
  <parent>
    <!-- 被继承的父项目的唯一标识符 -->
    <groupId>org.springframework.boot</groupId>
    <!-- 被继承的父项目的构件标识符 -->
    <artifactId>spring-boot-starter-parent</artifactId>
    <!-- 被继承的父项目的版本 --> 
    <version>2.2.4.RELEASE</version>
  </parent>
  <modules>
    <!--注册中心项目-->
    <module>spring-register</module>
    <module>springcloud-eureka</module>
    <module>springcloud-common</module>
    <module>springcloud-zuul</module>
    <module>springcloud-eureka-cluster</module>
  </modules>
 
  <!-- 该元素描述了项目相关的所有依赖。 这些依赖组成了项目构建过程中的一个个环节。自动从项目定义的仓库中下载。--> 
  <dependencyManagement>
    <dependencies>
      <dependency>
        <!-- 依赖的group ID --> 
        <groupId>org.springframework.cloud</groupId>
        <!-- 依赖的artifact ID -->
        <artifactId>spring-cloud-dependencies</artifactId>
        <!-- 依赖的版本号。 在Maven 2里, 可以配置成版本号的范围。 -->
        <version>Hoxton.RELEASE</version>
        <!-- 依赖类型。 -->
        <type>pom</type>
        <!-- 依赖范围。在项目发布过程中,帮助决定哪些构件被包括进来
           - compile :默认范围,用于编译 
           - provided:类似于编译,但支持你期待jdk或者容器提供,类似于classpath 
           - runtime: 在执行时需要使用 
           - test: 用于test任务时使用 
           - system: 需要外在提供相应的元素。通过systemPath来取得 
           - systemPath: 仅用于范围为system。提供相应的路径 
           - optional: 当项目自身被依赖时,标注依赖是否传递。用于连续依赖时使用 --> 
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>
  <!--使用aliyun镜像-->
  <repositories>
    <repository>
      <id>alimaven</id>
      <name>Maven Aliyun Mirror</name>
      <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
      <releases>
        <enabled>true</enabled>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </repository>
  </repositories>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>

第二に、レジストリプロジェクトspringcloud-ユーレカを作成

マイクロサービスアーキテクチャは、サービス管理の中核部分である、ガバナンスの最も基本的なコンポーネントは、登録されたサービス・センターです。春の雲のサポート飼育係、領事とユーレカ、公式の推薦ユーレカ。

親ディレクトリの達人で指定されたMavenのモジュールを作成します

ここに画像を挿入説明

ファイルの依存関係にのpom.xmlを追加

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.springcloud</groupId>
    <artifactId>springcloud-root</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>
  <artifactId>springcloud-eureka</artifactId>
  <name>springcloud-eureka</name>
  <url>http://maven.apache.org</url>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  <dependencies>
    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
      <version>2.2.1.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-webflux</artifactId>
      <version>2.2.4.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>
春・クラウド・スターター・ユーレカ・サーバー:jarファイルが欠落している错误
Project build error: 'dependencies.dependency.version' for org.springframework.cloud:spring-cloud-starter-eureka-server:jar is missing.

変更:春 - クラウドスターターユーレカ・サーバーのスプリング・クラウド・スターター・ネットフリックス - ユーレカ・サーバーへ

レジストリ起動クラスを追加します。

ここに画像を挿入説明

package org.springcloud.eureka;

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

@SpringBootApplication //spring-boot 启动注解
@EnableEurekaServer // spring-cloud 服务注解

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

Application.yml設定ファイル

ここに画像を挿入説明

spring:
  application:
    # 当前服务名
    name: springcloud-eureka
  freemarker:
    prefer-file-system-access: false
server:
  # 端口号
  port: 8899
---
eureka:
  instance:
    hostname: localhost
  client:
    # 检索服务
    fetch-registry: false
    # 是否将自己注册到eureka
    register-with-eureka: false
    # 客户端默认去这个地址找注册中心
    service-url:
      defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
  server:
    # 当eureka启动时,不能从集群节点中获取到instance注册信息,应该等多久
    wait-time-in-ms-when-sync-empty: 0
    enable-self-preservation: true
    # eureka多长时间更新一次数据
    peer-eureka-nodes-update-interval-ms: 100000
ERRORのorg.springframework.boot.SpringApplication - アプリケーションの実行に失敗しました错误
15:02:33.112 [main] ERROR org.springframework.boot.SpringApplication - Application run failed
java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.<init>([Ljava/lang/Object;)V
	at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:157)
	at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:98)
	at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:64)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
	at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:76)
	at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:53)
	at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:345)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:308)
	at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:140)
	at org.springcloud.eureka.RegisterMain.main(RegisterMain.java:16)

春のブートバージョンとの互換性を解決することができるそれらのspringbootとバージョンspringcloud対応する、のpom.xml内の設定ファイルを変更引き起こしました。

対応関係春ブーツバージョンと春の雲のバージョン:
https://spring.io/projects/spring-cloud

春の雲 春ブーツ
ホクストン 2.2.xの
グリニッジ 2.1.xの
フィンチリー 互換性のある春ブート2.0.xのは、春ブーツの1.5.xと互換性がありません
Dalston和エッジウェア 互換性のある春ブート1.5.xのは、春ブーツの2.0.xと互換性がありません
カムデン 春ブーツの1.5.xにも対応の互換性春ブーツ1.4.xの、
ブリクストン 春ブート1.4.xのと互換性の互換性春ブート1.3.xの、また、
アプリケーションは、TO STARTをFAILED错误
***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.springframework.cloud.client.discovery.health.DiscoveryCompositeHealthIndicator.<init>(DiscoveryCompositeHealthIndicator.java:41)

The following method did not exist:

    org.springframework.boot.actuate.health.CompositeHealthIndicator.<init>(Lorg/springframework/boot/actuate/health/HealthAggregator;)V

The method's class, org.springframework.boot.actuate.health.CompositeHealthIndicator, is available from the following locations:

    jar:file:/E:/SpringBoot/Maven-Repository/org/springframework/boot/spring-boot-actuator/2.2.4.RELEASE/spring-boot-actuator-2.2.4.RELEASE.jar!/org/springframework/boot/actuate/health/CompositeHealthIndicator.class

It was loaded from the following location:

    file:/E:/SpringBoot/Maven-Repository/org/springframework/boot/spring-boot-actuator/2.2.4.RELEASE/spring-boot-actuator-2.2.4.RELEASE.jar

対応のspringcloudのspringbootとバージョンを解決することができます。

反応性のWebサーバーを起動することができません错误
org.springframework.context.ApplicationContextException: Unable to start reactive web server; nested exception is org.springframework.context.ApplicationContextException: Unable to start ReactiveWebApplicationContext due to missing ReactiveWebServerFactory bean.
	at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.onRefresh(ReactiveWebServerApplicationContext.java:81) ~[spring-boot-2.2.4.RELEASE.jar:2.2.4.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544) ~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:66) ~[spring-boot-2.2.4.RELEASE.jar:2.2.4.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) ~[spring-boot-2.2.4.RELEASE.jar:2.2.4.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.2.4.RELEASE.jar:2.2.4.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.2.4.RELEASE.jar:2.2.4.RELEASE]
	at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:140) [spring-boot-2.2.4.RELEASE.jar:2.2.4.RELEASE]
	at org.springcloud.eureka.RegisterMain.main(RegisterMain.java:15) [classes/:na]
Caused by: org.springframework.context.ApplicationContextException: Unable to start ReactiveWebApplicationContext due to missing ReactiveWebServerFactory bean.
	at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.getWebServerFactoryBeanName(ReactiveWebServerApplicationContext.java:100) ~[spring-boot-2.2.4.RELEASE.jar:2.2.4.RELEASE]
	at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.createWebServer(ReactiveWebServerApplicationContext.java:88) ~[spring-boot-2.2.4.RELEASE.jar:2.2.4.RELEASE]
	at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.onRefresh(ReactiveWebServerApplicationContext.java:78) ~[spring-boot-2.2.4.RELEASE.jar:2.2.4.RELEASE]

webflux依存性を追加します。

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-webflux</artifactId>
  <version>2.2.4.RELEASE</version>
</dependency>

ファイル名を指定して実行起動クラス、訪問のhttp:// localhostを:8899、以下の図のに
ここに画像を挿入説明
レジストリが完了しました。

第三に、レジストリのパスワードの設定

pom.xmlでの増加:

   <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-security</artifactId>
      <version>2.2.4.RELEASE</version>
    </dependency>

このバージョン5月ウェブサイトで:
https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-security

application.yml増加の設定ファイル

spring:
  application:
    name: springcloud-eureka
  freemarker:
    prefer-file-system-access: false
  security:
    basic: 
      enable: true
    user: 
      name: admin
      password: 123456
server:
  port: 8899
---
eureka:
  instance:
    hostname: localhost
  client:
    fetch-registry: false
    register-with-eureka: false
    service-url:
      defaultZone: http://${security.user.name}:${security.user.password}@${eureka.instance.hostname}:${server.port}/eureka/
  server:
    wait-time-in-ms-when-sync-empty: 0
    enable-self-preservation: true
    peer-eureka-nodes-update-interval-ms: 100000

// localhostを:のhttpで再び開始した後8899、次の図は、
ここに画像を挿入説明
ページを入力するためのユーザー名とパスワードを入力してください

第四に、レジストリにサービスレジストリを作成します

Mavenのモジュールプロジェクトを作成します。
ここに画像を挿入説明
ここに画像を挿入説明

ファイルの依存関係にのpom.xmlを追加

<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.springcloud</groupId>
    <artifactId>springcloud-root</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>
  <artifactId>springcloud-common</artifactId>
  <name>springcloud-common</name>
  <url>http://maven.apache.org</url>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  <dependencies>
    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
      <version>2.2.1.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-webflux</artifactId>
      <version>2.2.4.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>

クライアントの起動クラスを追加します。

package org.springcloud.common;

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

@SpringBootApplication
@EnableEurekaClient //Eureka Client

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

Application.yml設定ファイル

spring:
  application:
    name: springcloud-common
  freemarker:
    prefer-file-system-access: false
  security:
    user:
      name: admin
      password: 123456
    
server:
  port: 8001
  
eureka:
  instance:
    hostname: localhost
  client:
    service-url:
      defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@${eureka.instance.hostname}:8899/eureka/

クライアントが起動クラスを実行し、あなたは以下に示すように、クライアントは、サーバーに登録されていることがわかります
ここに画像を挿入説明

任意の既知のサーバー上のすべての要求を実行することはできません错误

eurka​​における安全認証クラスのサービスを追加
ここに画像を挿入説明

package org.springcloud.eureka;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.http.SessionCreationPolicy;

@EnableWebSecurity
@Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        // Configure HttpSecurity as needed (e.g. enable http basic).
        http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.NEVER);
        http.csrf().disable();
        //为了可以使用 http://${user}:${password}@${host}:${port}/eureka/ 这种方式登录,所以必须是httpBasic,
        http.authorizeRequests().anyRequest().authenticated().and().httpBasic();
    }
}

再実行します。

五、ユーレカ高可用性クラスタ

ここに画像を挿入説明
application.ymlファイルコピー三分の:アプリケーションpeer1.yml、アプリケーション・peer2.yml 、アプリケーション-peer3.yml。
ここに画像を挿入説明
次のようにCIが追加されました。

  • アプリケーションpeer1.yml
spring:
  application:
    name: springcloud-eureka-cluster
  freemarker:
    prefer-file-system-access: false
  security:
    user: 
      name: admin
      password: 123456
server:
  port: 8897
---
eureka:
  instance:
    hostname: eureka-peer1.com
    instance-id: eureka-peer1
  client:
    fetch-registry: true
    register-with-eureka: true
    service-url:
      defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@eureka-peer2.com:8898/eureka/,http://${spring.security.user.name}:${spring.security.user.password}@eureka-peer3.com:8899/eureka/
  • アプリケーションpeer2.yml
spring:
  application:
    name: springcloud-eureka-cluster
  freemarker:
    prefer-file-system-access: false
  security:
    user: 
      name: admin
      password: 123456
server:
  port: 8898
---
eureka:
  instance:
    hostname: eureka-peer2.com
    instance-id: eureka-peer2
  client:
    fetch-registry: true
    register-with-eureka: true
    service-url:
      defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@eureka-peer1.com:8897/eureka/,http://${spring.security.user.name}:${spring.security.user.password}@eureka-peer3.com:8899/eureka/
  • アプリケーションpeer3.yml
spring:
  application:
    name: springcloud-eureka-cluster
  freemarker:
    prefer-file-system-access: false
  security:
    user: 
      name: admin
      password: 123456
server:
  port: 8899
---
eureka:
  instance:
    hostname: eureka-peer3.com
    instance-id: eureka-peer3
  client:
    fetch-registry: true
    register-with-eureka: true
    service-url:
      defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@eureka-peer1.com:8897/eureka/,http://${spring.security.user.name}:${spring.security.user.password}@eureka-peer2.com:8898/eureka/

変更C:\ WINDOWS \ System32に\ drivers \ etcに\ホスト

127.0.0.1 eureka-peer1.com eureka-peer2.com eureka-peer3.com

spring.profiles.activeプロパティを介した3台のサーバを起動するために、生成ジャーパッケージをインストールしますMavenのでした。

cd E:\SpringBoot\SpringCloud\springcloud-root\springcloud-eureka-cluster\target
java -jar springcloud-eureka-cluster-0.0.1-SNAPSHOT.jar --spring.profiles.active=peer1
java -jar springcloud-eureka-cluster-0.0.1-SNAPSHOT.jar --spring.profiles.active=peer2
java -jar springcloud-eureka-cluster-0.0.1-SNAPSHOT.jar --spring.profiles.active=peer3

また、実行構成で起動するように設定することができます
ここに画像を挿入説明

  • アクセスhttp://eureka-peer1.com:8897/
    ここに画像を挿入説明

  • アクセスhttp://eureka-peer2.com:8898/
    ここに画像を挿入説明

  • アクセスhttp://eureka-peer3.com:8899/
    ここに画像を挿入説明

ユーレカクラスタノードは利用できません、レプリカでサービスエラーが登録されています

  1. 各ノードのアプリケーション名が同じでなければなりません
  2. 同じマシン内の各ノードは、ホスト名の必要性は、ローカルホストに記入するローカルテストは、各ノードは独自のホストを使用する場合
  3. 好むとIPアドレスのデフォルト値はtrueまたはない塗りつぶしに設定されています。
  4. -ユーレカ・登録し、フェッチ・レジストリが真であります
  5. defaultZoneは、すべてのノードで自分以外のクラスタ構成項目でホストに構成された独自のドメイン名を使用する必要がlocalhostは使用しません。

いいえ、コンパイラは、この環境で提供されていません。おそらくあなたは、JREではなくJDK上で実行されている?错误

https://blog.csdn.net/lslk9898/article/details/73836745

第六に、複数のインスタンス・サービス・プロバイダを起動

それぞれ開始複数springcloud-ユーレカ・プロバイダインスタンス、ポート8001,8002および8003、
ここに画像を挿入説明

  • アプリケーションprovider1.yml
spring:
  application:
    name: springcloud-eureka-provider
  freemarker:
    prefer-file-system-access: false
  security:
    user:
      name: admin
      password: 123456
    
server:
  port: 8001
  
eureka:
  instance:
    hostname: eureka-provider1.com
    instance-id: eureka-provider1
  client:
    service-url:
      defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@eureka-peer1.com:8897/eureka/,http://${spring.security.user.name}:${spring.security.user.password}@eureka-peer2.com:8898/eureka/,http://${spring.security.user.name}:${spring.security.user.password}@eureka-peer3.com:8899/eureka/
  • アプリケーションprovider2.yml
spring:
  application:
    name: springcloud-eureka-provider
  freemarker:
    prefer-file-system-access: false
  security:
    user:
      name: admin
      password: 123456
    
server:
  port: 8002
  
eureka:
  instance:
    hostname: eureka-provider2.com
    instance-id: eureka-provider2
  client:
    service-url:
      defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@eureka-peer1.com:8897/eureka/,http://${spring.security.user.name}:${spring.security.user.password}@eureka-peer2.com:8898/eureka/,http://${spring.security.user.name}:${spring.security.user.password}@eureka-peer3.com:8899/eureka/
  • アプリケーションprovider3.yml
spring:
  application:
    name: springcloud-eureka-provider
  freemarker:
    prefer-file-system-access: false
  security:
    user:
      name: admin
      password: 123456
    
server:
  port: 8003
  
eureka:
  instance:
    hostname: eureka-provider3.com
    instance-id: eureka-provider3
  client:
    service-url:
      defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@eureka-peer1.com:8897/eureka/,http://${spring.security.user.name}:${spring.security.user.password}@eureka-peer2.com:8898/eureka/,http://${spring.security.user.name}:${spring.security.user.password}@eureka-peer3.com:8899/eureka/

変更C:\ WINDOWS \ System32に\ drivers \ etcに\ホスト

127.0.0.1 eureka-provider1.com eureka-provider2.com eureka-provider3.com

実行構成によって起動の設定
ここに画像を挿入説明

ビューユーレカレジストリ

http://eureka-peer1.com:8897/
ここに画像を挿入説明
http://eureka-peer2.com:8898/,http://eureka-peer3.com:8899/は、上記の結果。
3つのサービスプロバイダインスタンスが正常に登録されました。

72元記事公開 ウォン称賛66 ビュー150,000 +を

おすすめ

転載: blog.csdn.net/miaodichiyou/article/details/104160284