Python 官方文档:入门教程 => 点击学习
目录简介 使用 简介 Zuul是spring cloud全家桶中的微服务api网关。 所有从设备或网站来的请求都会经过Zuul到达后端的Netflix应用程序 Z
提供: 代理,过滤和路由三大功能
导入依赖
<!--zuul组件、zuul需要注册至eureka中-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zuul</artifactId>
<version>1.4.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<version>2.0.2.RELEASE</version>
</dependency>
配置文件
server:
port: 9527
spring:
application:
name: SpringCloud-zuul
eureka:
client:
service-url:
defaultZone: Http://eureka1:7001/eureka/,http://eureka2:7002/eureka/,http://eureka3:7003/eureka/
instance:
instance-id: zull9527.com #别名
开启支持
@SpringBootApplication
@EnableZuulProxy//开启zuul支持,默认注册到Eureka
public class Zuul9527Application {
public static void main(String[] args) {
SpringApplication.run(Zuul9527Application.class,args);
}
}
此时我们可以通过 地址:端口号/服务名称/服务 来访问了
注意:此处需在host文件添加 127.0.01 www,zuultest.com
为了不使我们的服务名称暴露我们可以在配置文件中添加
zuul:
routes:
xxx.serviceId: provider-name # xxx代表任意名称
xxx.path: /mydept
public static class ZuulRoute {
private String path;
private String serviceId;
}
以上就是SprinGCloud Zuul的使用简介的详细内容,更多关于SpringCloud Zuul的使用的资料请关注编程网其它相关文章!
--结束END--
本文标题: SpringCloud Zuul的使用简介
本文链接: https://www.lsjlt.com/news/123747.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0