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来访问

    访问方式

  • 相关阅读:
    Python列表去重的三种方法
    关于Python的 a, b = b, a+b
    Python爬取B站视频信息
    Linux文件管理命令
    (一)MySQL学习笔记
    Linux特殊字符含义
    在父容器div中图片下方有一条空隙问题
    对Json的各种遍历方法
    for循环使用append问题
    IE兼容性
  • 原文地址:https://www.cnblogs.com/xiaoruirui/p/11961232.html
Copyright © 2011-2022 走看看