Spring Cloud GateWay 配置
添加依赖:
gateway 2.1.3
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-gateway</artifactId> <version>2.1.3.RELEASE</version> </dependency>
spring boot 2.1.3
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>2.1.3.RELEASE</version> <type>pom</type> <scope>import</scope> </dependency>
spring: cloud: nacos: discovery: server-addr: localhost:8848 config: namespace: 7d8f0f5a-6a53-4785-9686-dd460158e5d4 #命名空间 group: DEV_GROUP file-extension: yml server-addr: localhost:8848 #Nacos服务注册中心地址 prefix: gateway # 网关服务名 refresh-enabled: true gateway: # routes: # - id: service-member # uri: lb://guli-member # predicates: #断言 # - Path=/guli-member/** # filters: # - StripPrefix=1 #去除路径前缀:/guli-member/ # - AddResponseHeader: X-Response-Foo, Bar discovery: #自动路由 通过nacos的服务名 locator: enabled: true lower-case-service-id: true
本文来自博客园,作者:宗神一,转载请注明原文链接:https://www.cnblogs.com/zhangmuchen/p/16281443.html