RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
如何解析springcloudgateway网关路由分配代码实例

这篇文章将为大家详细讲解有关如何解析springcloudgateway网关路由分配代码实例,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。

创新互联从2013年创立,是专业互联网技术服务公司,拥有项目成都网站设计、成都网站建设网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元湘阴做网站,已为上家服务,为湘阴各地企业和个人服务,联系电话:028-86922220

1, 基于父工程,新建一个模块

2,pom文件添加依赖

         org.springframework.cloud      spring-cloud-starter-gateway              com.alibaba.cloud      spring-cloud-starter-alibaba-nacos-discovery      

3,添加配置

server: port: 9091spring: application:  name: gateway3 cloud:  nacos:   discovery:    server-addr: localhost:8848    namespace: c22e5019-0bee-43b1-b80b-fc0b9d847501    register-enabled: false  gateway:   routes:    - id: demo_route     uri: lb://demo     predicates:      - Path=/demo/**    - id: demo2_test     uri: lb://demo2     predicates:      - Path=/user/**

4,编写启动类

@SpringBootApplication@EnableDiscoveryClientpublic class Gateway3Application {  public static void main(String[] args) {        SpringApplication.run(Gateway3Application.class, args);  }}

5,访问http://localhost:9091/demo或http://localhost:9091/demo2路由到指定的服务

关于如何解析springcloudgateway网关路由分配代码实例就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。


名称栏目:如何解析springcloudgateway网关路由分配代码实例
分享路径:http://scyingshan.cn/article/jhdgpp.html