server:
port: 8761
spring:
application:
name: sc-service-gateway
cloud:
gateway:
discovery:
locator:
enabled: false
lowerCaseServiceId: true
routes:
- id: sc-service-hi
uri: lb://SC-SERVICE-HI
predicates:
- Path=/demo/**
filters:
- StripPrefix=1
spring.cloud.gateway.discovery.locator.enabled默认是 false
如果 true 的话,localhost:8761/sc-service-hi/hi?name=zhangsan(就是直接可以从网关+提供服务的服务名就可以正常访问了)
如果是 false 的话,上面的访问不生效,必须通过/demo 开头的 url 才可以访问到
-Path 是接受http://localhost:8761/demo/hi?name=zhangsan (以/demo开头的 url),StripPrefix=1(转发到sc-service-hi中的接口是去掉/demo)转发到注册中心sc-service-hi服务上的/hi这个接口上 面
spring.application.name 只有消费者指的不是自己的服务名,而是指的服务提供的名字
- Path=/v2x/platform/device/** filters: - StripPrefix=2 映射到以 device 开头的所有接口,包括、device/test和/device/test/a