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

    访问方式

  • 相关阅读:
    day4笔记
    day3笔记
    day2 python基础 while 循环补充
    day1笔记 初识python,paython基础
    指针-1
    scanf输入与getchar的比较
    [递归]母牛的故事
    安装mysql以及遇到的问题解决
    33.指针
    32.字符串
  • 原文地址:https://www.cnblogs.com/xiaoruirui/p/11961232.html
Copyright © 2011-2022 走看看