外部に露出して使用zuul統一ゲートウェイ・インターフェース
新しいプロジェクトバネ-zuulを作成します。1.
ポンポンの2.はじめに
< 依存性> < のgroupId > org.springframework.cloud </ のgroupId > < たartifactId >ばねクラウドスタータのNetflix-zuul </ たartifactId > </ 依存>
3.設定
春:
アプリケーション:
名前:春-zuul のhttp:
エンコード:
文字セット:UTF-8#设置请求返回UTF-8编码
力:真
ユーレカ:
クライアント:
サービスURL:
defaultZoneます。http:// localhost:8761 /ユーリカ/
インスタンス:
好む-IPアドレス:真の
サーバー:
ポート:8082
4. [スタート]クラスのノート
輸入org.springframework.boot.SpringApplication。 輸入org.springframework.boot.autoconfigure.SpringBootApplication。 輸入org.springframework.cloud.netflix.eureka.EnableEurekaClient; 輸入org.springframework.cloud.netflix.zuul.EnableZuulProxy; @SpringBootApplication @EnableEurekaClient @EnableZuulProxy パブリック クラスSpringZuulApplication { 公共 静的 ボイドメイン(文字列[]引数){ SpringApplication.run(SpringZuulApplication。クラス、引数)。 } }
マイクロフォーマットURLそれぞれのサービスにアクセスすることによりZuulトランジットサービス: {basePathを} / {spring.application.name} / URL
{basePathを} zuulパスゲートウェイプログラムの起動後
{spring.application.name}はそれぞれ特定のマイクロサービス名をサブシステムは、すなわち、設定ファイルはspring.application.nameある
URL:HTTPカスタム・アプリケーション・インターフェースのそれぞれ。
テスト:
完全なコードへのアクセス:https://github.com/halouprogramer/spring-cloud-demo