zoukankan      html  css  js  c++  java
  • spring cloud网关

    网关的作用

    是为服务的入口,需要通过网关我们经行,登录认证,流量限制,请求监控,请求分发等等。

    还是复制一份以前写过的代码,只需要主配置类,和配置文件就可以了

    导包

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

    配置文件

    如果想直接通过服务器名称访问我们可以通过不配置zuul直接访问http://localhost:4000/order-server/customer/user/1

    eureka:
    client:
    serviceUrl:
    defaultZone: http://localhost:1000/eureka/#注册中心地址
    instance:
    ip-address: true #使用ip配置
    instance-id: zuul-server #指定服务的id
    server:
    port: 4000
    spring:
    application:
    name: zuul-server
    zuul:
    ignoredServices: '*' #不允许使用服务名称访问,这里是指的application:name,开启这个配置的时候我们需要开启routes
    prefix: /hrm #统一前缀
    routes:
    order-server: /order/** #类似于取别名,这样访问order-server的时候就可以通过order来访问

    访问方式

  • 相关阅读:
    2020暑假牛客多校9 B
    2020暑假牛客多校10 C -Decrement on the Tree (边权转点权处理)
    HDU 5876 补图的最短路
    CSP初赛复习
    遗传算法
    排列组合
    和式 sigma的使用
    多项式的各种操作
    三分
    NOIP2018普及游记
  • 原文地址:https://www.cnblogs.com/xiaoruirui/p/11961232.html
Copyright © 2011-2022 走看看