1.创建一个springboot项目作为网关(web+eureka-client+zuul)
2.实现步骤
2.1导依赖
org.springframework.cloud
spring-cloud-starter-netflix-eureka-client
org.springframework.cloud
spring-cloud-starter-netflix-zuul
2.2开启服务
启动类加注解:@EnableZuulProxy
2.3配置(默认和自定义同时生效)·
1.默认的路由配置
默认规则:http://localhost:8080/服务名称/映射方法参数
例如:http://localhost:8080/cart-service/cart/getById/1
2.自定义路由配置
例如:http://localhost:8080/cart/cart/getById/1
springcloud-zuul路由器的配置
最新推荐文章于 2023-06-18 11:06:47 发布