In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Most people do not understand the knowledge points of this article "how to use Zuul Gateway in Spring Cloud Microservice Architecture", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this article "how to use Zuul Gateway in Spring Cloud Microservice Architecture".
Brief introduction
Zuul is the micro-service API gateway in the Spring Cloud family bucket. All requests from the device or website will go through Zuul to the back-end Netflix application
Zuul mainly provides routing (request forwarding) and filtering
Zuul will eventually be injected into Eureka
Provide three major functions: proxy, filtering and routing
Use
Import dependency
Org.springframework.cloud spring-cloud-starter-zuul 1.4.6.RELEASE org.springframework.cloud spring-cloud-starter-netflix-eureka-client 2.0.2.RELEASE
Configuration file
Server: port: 9527spring: application: name: springcloud-zuuleureka: client: service-url: defaultZone: http://eureka1:7001/eureka/,http://eureka2:7002/eureka/,http://eureka3:7003/eureka/ instance: instance-id: zull9527.com # alias
Enable support
@ SpringBootApplication@EnableZuulProxy// enables zuul support and registers to Eurekapublic class Zuul9527Application {public static void main (String [] args) {SpringApplication.run (Zuul9527Application.class,args);}} by default
At this point, we can access it by address: Port number / service name / service.
Note: add 127.0.01 www,zuultest.com to the host file here
In order not to expose our service name, we can add to the configuration file
Zuul: routes: xxx.serviceId: provider-name # xxx represents any name xxx.path: / mydept/** ignored-services: provider-name # No longer access through this path, that is, direct access through the service name prefix: / lin # access path must be prefixed with / lin
This can only be accessed through the address: Port number / lin/mydept/ service
Add: why serviceId and path are used in configuration files and route is stored as key-value pairs in zull
Public void setRoutes (Map routes) {this.routes = routes;}
And in ZuulProperties,
/ * Represents a Zuul route. * / public static class ZuulRoute {/ * The path (pattern) for the route, e.g. / foo/**. * / private String path; / * * The service ID (if any) to map to this route. You can specify a physical URL or * a service, but not both. * / private String serviceId;} the above is about the article "how to use Zuul Gateway in Spring Cloud Micro Service Architecture". I believe you all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to learn more about it, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 278
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.