Zuul(路由网关)

zuul

    • 引入依赖
    • 配置yml
    • 主启动类
    • 访问路径

引入依赖

<dependency>
        <groupId>org.springframework.cloudgroupId>
        <artifactId>spring-cloud-starter-netflix-zuulartifactId>
dependency>
<dependency>
	   <groupId>org.springframework.cloudgroupId>
	   <artifactId>spring-cloud-starter-netflix-eureka-clientartifactId>
dependency>

配置yml

server:
  port: 9527
spring:
  application:
    name: microservicecloud-zuul-gateway

#将zuul注册进eureka
eureka:
  client:
    service-url:
      defaultZone: http://eureka7001.com:7001/eureka, http://eureka7002.com:7002/eureka, http://eureka7003.com:7003/eureka
  instance:
    instance-id: gateway-9527.com
    prefer-ip-address: true

zuul:
  routes:
    mydept.serviceId: microservicecloud-dept #域名映射
    mydept.path: /mydept/**
  ignored-services: "*" #隐藏所有微服务名称
  prefix: /lqk  #公共前缀
  host:
    maxTotalConnections: 10000
    maxPerRouteConnections: 10000
  semaphore:
      max-semaphores: 200

主启动类

//添加该注解
@EnableZuulProxy

访问路径

http://myzuul.com:9527/lqk/mydept/**

参考1


  1. 尚硅谷周阳springcloud第一季zuul ↩︎

你可能感兴趣的:(微服务)