티스토리 뷰
spring cloud gateway 를 Local 에 설정한 과정을 작성.
1. spring boot project 생성
spring boot initializr ( https://start.spring.io/ ) 에서 spring boot 프로젝트를 생성하여 저장합니다.
2. Spring Cloud Gateway 관련 의존성 추가.
build.gradle
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-gateway', version: '2.2.1.RELEASE'
3. RouteLocator 정의
java version : SpringCloudSampleApplication.java
@SpringBootApplication
public class SpringCloudSampleApplication {
public static void main(String[] args) {
SpringApplication.run(SpringCloudSampleApplication.class, args);
}
@RefreshScope
@Bean
public RouteLocator myRoutes(RouteLocatorBuilder builder) {
return builder.routes()
.route(p -> p.path("/order/**").uri("http://localhost:8081"))
.route(p -> p.path("/shipment/**").uri("http://localhost:8082"))
.build();
}
}
yml version : bootstrap.yml
spring:
cloud:
gateway:
routes:
- id: order
uri: http://localhost:8081
predicates:
- Path=/order/**
- id: shipment
uri: http://localhost:8082
predicates:
- Path=/shipment/**
여기 까지 설정을 완료하면 Path Route Predicate 에 매칭된 요청들은 각 route 규칙에 따라서 전달된다.
localhost:8080/order/list -> localhost:8081/order/list
localhost:8080/shipment/1 -> localhost:8082/shipment/1
'Spring Framework > Spring Cloud' 카테고리의 다른 글
Spring Cloud Gateway dynamic configuration change (0) | 2020.11.29 |
---|---|
Spring Cloud Gateway mapping custom data to configuration - Route meta data to RoutePredication (0) | 2020.11.29 |
Spring Cloud Gateway mapping custom data to configuration - Meta Data 정의 (0) | 2020.11.29 |
Spring Cloud Gateway RateLimiter 적용 (1) | 2020.08.04 |
Spring Cloud Gateway (0) | 2020.07.23 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- DyanomoDB
- RouteDefinition
- notify()
- GlobalFilter
- mariadb-connector-j
- dynamodb
- rate limit
- msyql-connector-java
- Seperate Chaining
- wait()
- RoutePredication
- Lazy
- spring cloud gateway
- MariaDB
- custom config data convertion
- getBoolean
- notifyAll()
- ConcurrentHashMap
- ResultSet
- aurora
- router
- AbstractMethodError
- reative
- N+1
- circurit breaker
- referencedColumnName
- Flux
- reactor
- HashMap
- mariada-connector
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
글 보관함