マルチサーバユーレカを構築するためのスプリングモジュール

モジュールを作成して1と2はEureka_user_service_2000のEureka_order_serice_3000顧客サービス側(以下一つだけ自分自身のはどのようなことができます変更します)

ポンポンで

<依存性> 
        <依存性> 
            <のgroupId> org.springframework.cloud </のgroupId> 
            <たartifactId>ばねクラウドスタータのNetflix、ユーレカクライアント</たartifactId> 
        </依存> 

        <依存性> 
            <のgroupId> org.springframework。ブート</ groupIdを> 
            <たartifactId>春・ブート・スターター・ウェブ</たartifactId> 
        </依存関係> 
    </依存関係>

 

 

3.主な構成や設定ファイルの種類

allication.yml中

ユーレカ:
  クライアント:
    serviceURLの:
      defaultzone:HTTP:// localhostを:1000 /ユーレカ/#登録センター住所の
サーバー:
  ポート: 2000 
春:
  アプリケーション:
    名:ユーザー -server

 

メインコンフィギュレーションクラス

パッケージcn.jiedada。

輸入org.springframework.boot.autoconfigure.SpringBootApplication。
輸入org.springframework.boot.builder.SpringApplicationBuilder。
輸入org.springframework.cloud.netflix.eureka.EnableEurekaClient; 

@SpringBootApplication 
@EnableEurekaClient 
パブリック クラスアプリケーション{
     公共 静的 ボイドメイン(文字列[]引数){
         新しい SpringApplicationBuilder(アプリケーションクラス).web().RUN(引数)。
    } 

}

コントローラ

パッケージcn.jiedada。

輸入org.springframework.web.bind.annotation.RequestMapping。
輸入org.springframework.web.bind.annotation.RestController; 

@RestController 
パブリック クラスUuserController { 
    @RequestMapping( "/" パブリック文字列の自宅(){
         リターン "こんにちは世界" ; 
    } 
}

あなたは次の成功を使用して、クライアントのページにサーバ側をオンにする必要があります

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

おすすめ

転載: www.cnblogs.com/xiaoruirui/p/11925717.html