SpringCloud学習シリーズ-Eurekaサービス登録と発見(2)

microservicecloud-ユーレカ-7001ユーレカのService Registryモジュールの構築

microservicecloud-ユーレカ-7001を作成して1

 

2.pom

<プロジェクトの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を>コム.atguigu.springcloud </ groupIdを> 
   <たartifactId> microservicecloud </たartifactId> 
   <バージョン> 0.0.1-SNAPSHOT </バージョン> 
  </親> 
 
  <たartifactId> microservicecloud-ユーレカ-7001 </たartifactId> 
 
  <依存性> 
   <! - -eurekaサーバ服务端- > 
   <依存> 
     <groupIdを> org.springframework.cloud </ groupIdを>
     <たartifactId>ばねクラウドスタータユーレカサーバ</たartifactId> 
   </依存>
   <! -修改后立即生效、热部署- > 
   <依存> 
     <groupIdを> org.springframework </ groupIdを> 
     <たartifactId>スプリング付き</たartifactId> 
   </依存関係> 
   <依存> 
     <groupIdを> org.springframework.boot </ groupIdを> 
     <たartifactId>春・ブート・デベロッパーツール</たartifactId> 
   </依存関係> 
  </依存関係> 
 
</プロジェクト>

3.yml

 
サーバー:
  ポート:7001 
 
ユーレカ:
  インスタンス:
    ホスト名:localhostを#eurekaサーバーインスタンス名の
  クライアント:
    登録-と-ユーレカ:偽#falseは、彼らがレジストリに自身を登録していないと述べました。
    フェッチ・レジストリを:偽#falseは、彼が最後のレジストリであることを特徴とする、私の義務は、サービスインスタンスを維持することで、あなたはサービスを検索する必要はありません
    サービス-URLを:
      HTTP:// $ {eureka.instance.hostname}:$ {サーバーdefaultzoneを.port}ユーレカサーバーアドレスの追跡および登録サービスとの対話/ユーレカ/#設定は、このアドレスに依存する必要があります。
 

4.EurekaServer7001_Appメイン起動クラス

以下のためのパッケージ変更com.atguigu.springcloud; 
 
インポートorg.springframework.boot.SpringApplication;
 インポートorg.springframework.boot.autoconfigure.SpringBootApplication;
 インポートorg.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 
 
@SpringBootApplication 
@EnableEurekaServer // EurekaServerサーバーサービス登録他のマイクロ着信受信起動クラスの終了、
パブリック クラスEurekaServer7001_App 
{ 
  公共 静的 ボイドメイン(文字列[]引数)
  { 
   SpringApplication.run(EurekaServer7001_App クラス、引数を); 
  } 
}
 
 

5.テスト

まずEurekaServerを開始します

http:// localhostを:7001 /

おすすめ

転載: www.cnblogs.com/XiangHuiBlog/p/12090705.html