springCloud(十三) spring cloud api网关 -zuul
2021-05-04 16:27
标签:desc info pac server 项目配置 lease str 设置 book springCloud(十三) spring cloud api网关 -zuul 标签:desc info pac server 项目配置 lease str 设置 book 原文地址:https://www.cnblogs.com/guhualin/p/13194527.html1: 相关图片
2:项目配置
1: pom.xml
2: ZuulApplication.java
package com.itlaoqi.springcloud.zuul;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
@EnableEurekaClient
@EnableZuulProxy
public class ZuulApplication {
public static void main(String[] args) {
SpringApplication.run(ZuulApplication.class, args);
}
}
3: 配置文件
spring:
application:
name: zuul-proxy
eureka:
client:
service-url:
defaultZone:
http://localhost:8761/eureka
zuul:
routes:
book-service-api:
path: /book/** #从zuul这端做的映射
serviceId: book-service #微服务名称
member-service-api:
path: /member/**
serviceId: member-service
server:
port: 80
3: 浏览器访问
http://localhost/book/test?param=123
{"param":"123","port":8081}
http://localhost/member/sendMess?phone=123
{"code":0,"message":"发送短信成功,手机号为:123"}
3: Zuul 进行负载均衡设置
文章标题:springCloud(十三) spring cloud api网关 -zuul
文章链接:http://soscw.com/index.php/essay/82334.html