SpringCloud Zuul 의 사용 안내
2931 단어 SpringCloudZuul
제공:에이전트,필터,루트 3 대 기능
쓰다
가 져 오기 의존
<!--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 ww,zuultest.com 을 추가 해 야 합 니 다.
Google 서비스 이름 이 노출 되 지 않도록 설정 파일 에 추가 할 수 있 습 니 다.
zuul:
routes:
xxx.serviceId: provider-name # xxx
xxx.path: /mydept/**
ignored-services: provider-name #
prefix: /lin # /lin
이 때 는 주소:포트 번호/lin/my dept/서비스 로 만 접근 할 수 있 습 니 다.추가:왜 설정 파일 에 serviceId 와 path 를 사용 하 는 지 zull 에서 route 는 키 쌍 으로 저 장 됩 니 다.
public void setRoutes(Map<String, ZuulRoute> routes) {
this.routes = routes;
}
Zuul Properties 에서
/**
* 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;
}
이상 은 SpringCloud Zuul 의 사용 프로필 에 대한 상세 한 내용 입 니 다.SpringCloud Zuul 의 사용 에 관 한 자 료 는 저희 의 다른 관련 글 을 주목 해 주 십시오!
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
[Spring Cloud] LoadBancer-01discoveryservice-eureka 라는 프로젝트를 생성한다 3개 항목을 추가한다. 1. DiscoveryserviceEurekaApplication.java 생성된 -application에 @EnableEu...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.