evaang-cloud(一):Gateway网关搭建

1:引入SpringCloud Gateway

	<dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-gateway</artifactId>
     </dependency>

2:路由方式

2.1:配置方式- applicaiton.yml
	spring:
	  application:
	    name: cloud-gateway
	  cloud:
	    gateway:
	      routes:
	      - id: path_route
	        uri: https://www.comang.top
	        predicates:
	        - Path=/auth/* 
2.2:JavaConfig方式在这里插入图片描述
2.3:Nacos方式
2.3.1:Nacos安装配置
2.3.2: 删除application.yml和RouteConfig文件
2.3.3:配置bootstrap.yml
		server:
		  port: 8080
		spring:
		  application:
		    name: evaang-gateway
		  profiles:
		    active: dev
		  cloud:
		    nacos:
		      # 在 Nacos Spring Cloud 中,dataId 的完整格式:${prefix}-${spring.profiles.active}.${file-extension},其中:prefix 默认为 spring.application.name
		      config:
		        server-addr: http://localhost:8848
		        # nacos配置内容数据格式
		        file-extension: yaml
2.3.4:配置nacos共享data id(共享DataID不支持@RefreshScope)-
			shared-configs:
				# 在Nacos控制台添加 share-dev.yaml配置
      			- share-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值