這篇文章給大家介紹springcloud中怎么實現(xiàn)zuul路由網(wǎng)關,內(nèi)容非常詳細,感興趣的小伙伴們可以參考借鑒,希望對大家能有所幫助。
1.簡介
當微服務對外提供接口訪問時,并且有多個微服務,外部如何訪問到具體的微服務?這時就可以使用網(wǎng)關的路由功能,依據(jù)url匹配將請求分別轉發(fā)到不同的服務上
2.使用
zuul除了有轉發(fā)功能,還有過濾功能,在網(wǎng)關層面可以對請求權限進行校驗,token信息生成,設置token信息過期等等,并且可以將token保存到redis緩存中。
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-zuul</artifactId></dependency>
application.yml文件中配置
spring: application: name: PublicGateWay //服務名server: port: 8081 //端口eureka: client: service-url: defaultZone: http://localhost:8083/eureka/ //注冊中心地址zuul: routes: api-user: //路由轉發(fā)配置一 path: /api-user/** //以/api-user/開頭的請求都會轉發(fā)到UserService服務中 serviceId: UserService api-order: path: /api-common/** //以/api-order/開頭的請求都會轉發(fā)到CommonIntegration服務中 serviceId: CommonIntegration
關于springcloud中怎么實現(xiàn)zuul路由網(wǎng)關就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。
網(wǎng)頁題目:springcloud中怎么實現(xiàn)zuul路由網(wǎng)關-創(chuàng)新互聯(lián)
當前鏈接:http://jinyejixie.com/article28/dssgjp.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站設計、微信小程序、小程序開發(fā)、自適應網(wǎng)站、商城網(wǎng)站、做網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容