A:ユーレカの紹介
ユーレカスプリングクラウドのNetflixはまた、コアモジュールの一つであり、サブモジュールです。クラウドサービスの発見とフェイルオーバーを実現するために、ロケーションサービス、中間層のために、サービスの発見、RESTベースのサービスのためにドライブ。学びspringcloudアーキテクチャは、BEGに追加することができます:3536247259は、サービス登録と発見はマイクロサービスシステムのために非常に重要です。サービスの発見と登録を使用すると、サービスコールの設定ファイルの日を変更する必要はありません、あなただけがサービスにアクセスできるよう、サービスの識別子を使用する必要があります。彼の機能は、登録センターのダボ(レジスタ)に似ています。
サービス発見:サービスの発見は、マイクロサービスインフラストラクチャの重要な原則の一つです。各クライアントを設定するために進んでしようとしているか、契約のいくつかのフォームは、非常に困難で、非常に壊れやすいと言うことができます。ユーレカは、サービスNetflixのサービスとクライアントの発見です。そのようなサービスは、高可用性および展開のために構成することができ、登録されたサービスのうち、各サービスのステータスは、互いに複製することができます。
サービス登録:ときに、クライアント・レジスタ(などのホストとポートの健康指標URL、自宅、など)は、独自のメタデータで提供ユーレカ、ユーレカには、各インスタンスによってサービスからのハートビートメッセージが表示されます。それは長く設定さよりもハートビートを受信できなかった場合の例は、通常のレジスタから削除されます
以下は基本的なサービスの登録と発見である
ユーレカサービスの発見および登録(登録センターを作成):2
1:春のブートに基づいてプロジェクトを作成し、のpom.xmlに必要なコンテンツ依存の導入は、
<?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>
<groupId>com.demo.springcloud</groupId>
<artifactId>eureka_register_service</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>eureka_register_service</name>
<description>Spring Cloud project</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.3.RELEASE</version>
<relativePath />
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Brixton.RELEASE</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>
</project>
2:起動クラスのアプリケーションを作成します。
package com.demo.springcloud;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@EnableEurekaServer
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
@EnableEurekaServerによって注釈は、他のアプリケーションにサービスレジストリを提供するために、対話を始めます。
3:起動するかどうか、使用のスペースに注意しないこと、プロファイルapplication.propertiesを作成し、エラー
はserver.port = 8000
ユーレカはeureka.client.register-で偽=
eureka.client.fetch-レジストリ=偽
eureka.client.serviceUrl.defaultZoneを= HTTP:// localhostを:$ {}はserver.port /ユーリカ/
4:構築bluid.shを行い、その後、メインメソッドを実行します。私は手動で日食でコンパイルしていなかったので、開始時刻がapplication.propertiesを読んでいません。
5:ビューのレジストリ
http://127.0.0.1:8000/次の図に見ることができますが、
非常にシンプルなああではない、そして人々が聞いている、でも、ログインIDとパスワードは、外部ネットワークに直接登録センターにアクセスすることはできませんされていない理由は、これは安全でああではありません。まあ、我々は、ログインIDとパスワードに参加します。