最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Spring Cloud基于zuul實(shí)現(xiàn)網(wǎng)關(guān)過程解析

 更新時(shí)間:2019年12月31日 14:47:05   作者:指尖,寫不盡  
這篇文章主要介紹了Spring Cloud基于zuul實(shí)現(xiàn)網(wǎng)關(guān)過程解析,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下

這篇文章主要介紹了Spring Cloud基于zuul實(shí)現(xiàn)網(wǎng)關(guān)過程解析,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下

利用zuul網(wǎng)關(guān)統(tǒng)一向外暴露接口

1.新建項(xiàng)目 spring-zuul

2.引入pom

<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-starter-netflix-zuul</artifactId>
</dependency>

3.配置

spring:
 application:
  name: spring-zuul
 http:
  encoding:
   charset: UTF-8 #設(shè)置請求返回UTF-8編碼
   force: true
eureka:
 client:
  service-url:
   defaultZone: http://localhost:8761/eureka/
 instance:
  prefer-ip-address: true
server:
 port: 8082

4.啟動類注解

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

@SpringBootApplication
@EnableEurekaClient
@EnableZuulProxy
public class SpringZuulApplication {

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

}

通過zuul中轉(zhuǎn)訪問各個(gè)業(yè)務(wù)微服務(wù)的url格式: {basePath}/{spring.application.name}/url

{basePath} : 網(wǎng)關(guān)zuul項(xiàng)目啟動后的路徑
{spring.application.name} 各個(gè)具體子系統(tǒng)的微服務(wù)名稱,即配置文件中配置的spring.application.name
url : 各個(gè)應(yīng)用自定的的http接口。

測試:

完整代碼訪問: https://github.com/halouprogramer/spring-cloud-demo

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

招远市| 合作市| 华宁县| 自贡市| 儋州市| 蓬安县| 金坛市| 扶绥县| 望都县| 古蔺县| 德令哈市| 新营市| 龙井市| 棋牌| 湾仔区| 凤山县| 昂仁县| 百色市| 城口县| 昌吉市| 盖州市| 双流县| 讷河市| 赤峰市| 扎鲁特旗| 潜江市| 南投县| 苏尼特左旗| 阿巴嘎旗| 吉安县| 兴和县| 西藏| 三原县| 祥云县| 揭东县| 城口县| 寿宁县| 高青县| 琼海市| 邢台县| 永顺县|