Retaining the Request's Path During Spring Cloud Gateway Failover - spring

Is there a way to externally configure Spring Cloud Gateway to failover to another data center? I'm thinking of something like this:
spring:
cloud:
gateway:
routes:
- id: test-service
uri: lb://test-service:8085/
predicates:
- Path=/test-service/**
filters:
- StripPrefix=1
- name: CircuitBreaker
args:
name: fallback
fallbackUri: forward:/fallback
#fallbackUri: forward:/fallback/test-service
- id: fallback
uri: http://${fallback_data_center}
predicates:
- Path=/fallback/**
---
spring:
config:
activate:
on-profile: data_center_1
fallback_data_center: dc2.com
---
spring:
config:
activate:
on-profile: data_center_2
fallback_data_center: dc1.com
The problem I run into is that the CircuitBreaker filter's fallbackUri parameter only supports forward schemed URIs. However, the path part of the request URL is overridden with the path in the forward URL. So there does not appear to be a way to failover with the path from the original request such as if this configuration had received a request of http://dc1.com/test-service/some/path without creating a configuration for every possible path.

At the time of writing this answer there is still now official way of doing a failover to another host.
What we are trying to achieve in our team is to have routes with Retry and CircuitBreaker filters which can fallback to another host keeping the original request unmodified ( request payload, header, query params and most importantly the API context path ) and just replacing the host so we can fallback to another datacenter.
We archived this by using the default Gateway Retry and CircuitBreaker filters and developing a custom FallbackController which just replaces the host with a configured property and keeps the rest of the request unmodified including the request context path:
#RestController
#RequestMapping("/fallback")
#ConditionalOnProperty(value="gateway.fallback.enabled", havingValue = "true")
public class FallbackController {
private final GatewayFallbackConfig gatewayFallbackConfig;
private final WebClient webClient;
public FallbackController(GatewayFallbackConfig gatewayFallbackConfig) {
this.gatewayFallbackConfig = gatewayFallbackConfig;
this.webClient = WebClient.create();
}
#PostMapping
Mono<ResponseEntity<String>> postFallback(#RequestBody(required = false) String body,
ServerWebExchangeDecorator serverWebExchangeDecorator) {
return fallback(body, serverWebExchangeDecorator);
}
#GetMapping
Mono<ResponseEntity<String>> getFallback(#RequestBody(required = false) String body,
ServerWebExchangeDecorator serverWebExchangeDecorator) {
return fallback(body, serverWebExchangeDecorator);
}
#PatchMapping
Mono<ResponseEntity<String>> patchFallback(#RequestBody(required = false) String body,
ServerWebExchangeDecorator serverWebExchangeDecorator) {
return fallback(body, serverWebExchangeDecorator);
}
#DeleteMapping
Mono<ResponseEntity<String>> deleteFallback(#RequestBody(required = false) String body,
ServerWebExchangeDecorator serverWebExchangeDecorator) {
return fallback(body, serverWebExchangeDecorator);
}
private Mono<ResponseEntity<String>> fallback(String body, ServerWebExchangeDecorator serverWebExchangeDecorator) {
ServerHttpRequest originalRequest = serverWebExchangeDecorator.getDelegate().getRequest();
WebClient.RequestBodySpec request = webClient.method(originalRequest.getMethod())
.uri(buildFallbackURI(originalRequest));
Optional.ofNullable(body)
.ifPresent(request::bodyValue);
return request.exchangeToMono(response -> response.toEntity(String.class));
}
private URI buildFallbackURI(ServerHttpRequest originalRequest) {
return UriComponentsBuilder.fromHttpRequest(originalRequest)
.scheme(gatewayFallbackConfig.getScheme())
.host(gatewayFallbackConfig.getHost())
.port(gatewayFallbackConfig.getPort())
.build(ServerWebExchangeUtils.containsEncodedParts(originalRequest.getURI()))
.toUri();
}
With an additional property configuration holder:
#Getter
#Component
#RefreshScope
#ConditionalOnProperty(value="gateway.fallback.enabled", havingValue = "true")
public class GatewayFallbackConfig {
private final String scheme;
private final String host;
private final String port;
private final Set<String> excludedHeaders;
public GatewayFallbackConfig(
#Value("${gateway.fallback.scheme:https}") String scheme,
#Value("${gateway.fallback.host}") String host,
#Value("${gateway.fallback.port:#{null}}") String port,
#Value("${gateway.fallback.headers.exclude}") Set<String> excludedHeaders) {
this.scheme = scheme;
this.host = host;
this.port = port;
this.excludedHeaders = excludedHeaders;
}
And we are using it with a route configuration like that:
- id: example-route
uri: http://localhost:8080
predicates:
- Path=/foo/bar/**
filters:
- name: CircuitBreaker
args:
name: exampleCircuitBreaker
fallbackUri: forward:/fallback
statusCodes:
- INTERNAL_SERVER_ERROR
- BAD_GATEWAY
- SERVICE_UNAVAILABLE
- name: Retry
args:
retries: 3
statuses: BAD_GATEWAY,SERVICE_UNAVAILABLE,GATEWAY_TIMEOUT
series: SERVER_ERROR
methods: GET,POST,PUT,DELETE
exceptions: org.springframework.cloud.gateway.support.NotFoundException,javax.security.auth.login.LoginException
backoff:
firstBackoff: 10ms
maxBackoff: 50ms
factor: 2
basedOnPreviousValue: false
gateway:
fallback:
scheme: https
host: some.other.host.com
enabled: true

Related

Rate limit of the Rest api using spring cloud gateway does not work

I tried to run, but I don’t understand that why don’t show an error when to occur rate limit to rest api.
GatewaySecureRateLimiterTest - I only observe the success of requests, but I do not see errors when limiting requests.
In addition, I would like to clarify for myself (I did not find it in the documentation):
I would like to clarify for myself (I didn't find this in the documentation):
how to change the error code to the address to which the response was sent that the resource is currently busy
is it possible to collect statistics and see which IP generates more requests than our endpoint can handle
the speed limit can only be configured using *. yml, or it can also be configured using Java, while ?
I would like to see it in tests. what is the restriction-it triggers and gets detailed information(for example, from which IP and how many requests and in what unit of time).
I also didn't fully understand what the meaning of these parameters is:
key determinant: "#{#userRemoteAddressResolver}"
reuse rate limiter.Top-up rate: 1
reuse rate limiter.Bandwidth: 1
For example, I would like to know what is the number of requests in these parameters, and what is the unit of time during which this number of requests should work ?
server:
port: ${PORT:8085}
logging.pattern.console: "%clr(%d{HH:mm:ss.SSS}){blue} %clr(---){faint} %clr([%15.15t]){yellow} %clr(:){red} %clr(%m){faint}%n"
spring:
application:
name: gateway-service
redis:
host: 192.168.99.100
port: 6379
output.ansi.enabled: ALWAYS
cloud:
gateway:
routes:
- id: account-service
uri: http://localhost:8085
predicates:
- Path=/account/**
filters:
- RewritePath=/account/(?<path>.*), /$\{path}
- name: RequestRateLimiter
args:
key-resolver: "#{#userKeyResolver}"
redis-rate-limiter.replenishRate: 10
redis-rate-limiter.burstCapacity: 20
config-security
#Configuration
//#ConditionalOnProperty("rateLimiter.secure")
#EnableWebFluxSecurity
public class SecurityConfig {
#Bean
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
http.authorizeExchange(exchanges ->
exchanges
.anyExchange()
.authenticated())
.httpBasic();
http.csrf().disable();
return http.build();
}
#Bean
public MapReactiveUserDetailsService users() {
UserDetails user1 = User.builder()
.username("user1")
.password("{noop}1234")
.roles("USER")
.build();
UserDetails user2 = User.builder()
.username("user2")
.password("{noop}1234")
.roles("USER")
.build();
UserDetails user3 = User.builder()
.username("user3")
.password("{noop}1234")
.roles("USER")
.build();
return new MapReactiveUserDetailsService(user1, user2, user3);
}
}
config
#Configuration
public class GatewayConfig {
#Bean
#Primary
#ConditionalOnProperty("rateLimiter.non-secure")
KeyResolver userKeyResolver() {
return exchange -> Mono.just("1");
}
// #Bean
// #ConditionalOnProperty("rateLimiter.secure")
KeyResolver authUserKeyResolver() {
return exchange -> ReactiveSecurityContextHolder.getContext()
.map(securityContext -> securityContext.getAuthentication()
.getPrincipal()
.toString()
);
}
}
test
#SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT,
properties = {"rateLimiter.non-secure=true"})
#RunWith(SpringRunner.class)
public class GatewayRateLimiterTest {
private static final Logger LOGGER =
LoggerFactory.getLogger(GatewayRateLimiterTest.class);
private Random random = new Random();
#Rule
public TestRule benchmarkRun = new BenchmarkRule();
private static final DockerImageName IMAGE_NAME_MOCK_SERVER =
DockerImageName.parse("jamesdbloom/mockserver:mockserver-5.11.2");
#ClassRule
public static MockServerContainer mockServer =
new MockServerContainer(IMAGE_NAME_MOCK_SERVER);
#ClassRule
public static GenericContainer redis =
new GenericContainer("redis:5.0.6")
.withExposedPorts(6379);
#Autowired
TestRestTemplate testRestTemplate;
#Test
#BenchmarkOptions(warmupRounds = 0, concurrency = 6, benchmarkRounds = 600)
public void testAccountService() {
String username = "user" + (random.nextInt(3) + 1);
HttpHeaders headers = createHttpHeaders(username,"1234");
HttpEntity<String> entity = new HttpEntity<>(headers);
ResponseEntity<Account> responseEntity =
testRestTemplate.exchange("/account/{id}",
HttpMethod.GET,
entity,
Account.class,
1);
LOGGER.info("Received: status->{}, payload->{}, remaining->{}",
responseEntity.getStatusCodeValue(),
responseEntity.getBody(),
responseEntity.getHeaders()
.get("X-RateLimit-Remaining"));
}
private HttpHeaders createHttpHeaders(String user, String password) {
String notEncoded = user + ":" + password;
String encodedAuth = Base64.getEncoder().encodeToString(notEncoded.getBytes());
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.add("Authorization", "Basic " + encodedAuth);
return headers;
}
}
repository
here

How to retry an external service when a call to an internal service fails using spring cloud gateway?

I'm implementing a service that mocks another service available on the web.
I'm trying to configure the spring cloud gateway to reroute requests to the public service when a call to my implementation fails.
I tried using the Hystrix filter the following way:
spring:
cloud:
gateway:
routes:
- id: foo
uri: http://my-internal-service/
filters:
- name: Hystrix
args:
name: fallbackcmd
fallbackUri: https://the.public.service/
Unfortunately, like the documentation says:
Currently, only forward: schemed URIs are supported. If the fallback is called, the request will be forwarded to the controller matched by the URI.
Therefore, I can't use fallbackUri: https://....
Is there any plan to support this feature soon?
Otherwise, what are my options for this particular use case?
I ended up with a kind of hacky workaround that seems to work for my particular use case (i.e. a GET request):
Create my own fallback controller in the Gateway application
Configure the hystrix fallback to point to that controller
Use the WebClient to call my public service
This is what the end result looks like:
application.yml
spring:
cloud:
gateway:
default-filters:
- name: AddResponseHeader
args:
name: X-Data-Origin
value: My internal service
routes:
- id: foo
uri: http://my-internal-service/
filters:
- name: Hystrix
args:
name: local-service-fallback
fallbackUri: forward:/fallback/foo
FallbackController.java
#RestController
#RequestMapping(path = "/fallback")
public class FallbackController {
private static final String fallbackUri = "https://the.public.service";
WebClient webClient;
public FallbackController() {
webClient = WebClient.create(fallbackUri);
}
#GetMapping("/foo")
Mono<MyResponse> foo(ServerWebExchange failedExchange) {
failedExchange.getResponse().getHeaders().remove("X-Data-Origin");
failedExchange.getResponse().getHeaders().add("X-Data-Origin", "The public service");
// Now call the public service using the same GET request
UriComponents uriComponents = UriComponentsBuilder.newInstance()
.uri(URI.create(fallbackUri))
.path("/path/to/service")
.queryParams(failedExchange.getRequest().getQueryParams())
.build();
return WebClient.create(uriComponents.toUriString())
.get()
.accept(MediaType.TEXT_XML)
.exchange()
.doOnSuccess(clientResponse -> {
// Copy the headers from the public service's response back to our exchange's response
failedExchange.getResponse().getHeaders()
.addAll(clientResponse.headers().asHttpHeaders());
})
.flatMap(clientResponse -> {
log.info("Data origin: {}",
failedExchange.getResponse().getHeaders().get("X-Data-Origin"));
return clientResponse.bodyToMono(MyResponse.class);
});
}
}
I had similar problem to solve.
I added new route for fallback and it worked.
.route(p -> p .path("/fallback/foo").uri("https://example.com"))

spring-cloud-gateway || need to configure global and application level and api level timeout

I am working in a spring-cloud-gateway project. Where I need to configure a Global Timeout/ application level timeout and api specific timeout. Following are my downstream apis:
#RestController
public class TestController {
// Should have global time out
#GetMapping("/global")
public Mono<ResponseEntity> testGlobalTimeOut(
#RequestHeader(name = "cId") UUID cId,
#RequestParam(name = "someNumber", required = false) Number someNumber) {
// Map<String, Object> map = populate Some Map Logic
return Mono.just(new ResponseEntity(map, HttpStatus.OK));
}
// Should have application level time out
#GetMapping("/appname/count")
public Mono<ResponseEntity> testApplicationTimeOut_1(
#RequestHeader(name = "cId") UUID cId,
#RequestParam(name = "someNumber", required = false) Number someNumber) {
// Map<String, Object> map = populate Some Map Logic
return Mono.just(new ResponseEntity(map, HttpStatus.OK));
}
// Should have application level time out
#GetMapping("/appname/posts")
public Mono<ResponseEntity> testApplicationTimeOut_2(
#RequestHeader(name = "cId") UUID cId,
#RequestParam(name = "someNumber", required = false) Number someNumber) {
// Map<String, Object> map = populate Some Map Logic
return Mono.just(new ResponseEntity(map, HttpStatus.OK));
}
// Should have api level time out
#GetMapping("/appname/posts/{postId}")
public Mono<ResponseEntity> getAPITimeOutWithPathVariable(
#RequestHeader(name = "cId") UUID cId,
#PathVariable(name = "postId") String postId) {
// Map<String, Object> map = populate Some Map Logic
return Mono.just(new ResponseEntity(map, HttpStatus.OK));
}
}
This apis are running as a downstream service. Now following are my route configurations for all these apis in my gateway-application:
# ============ Application Timeout =============
- id: application_timeout_route_1
uri: http://localhost/appname/count
predicates:
- Path=/withapplicationtimeout1**
filters:
- Hystrix=appTimeOut
- id: application_timeout_route_2
uri: http://localhost/appname/posts
predicates:
- Path=/withapplicationtimeout2**
filters:
- Hystrix=appTimeOut
# ============ API Level Timeout ===========
- id: api_timeout_route
uri: http://localhost
predicates:
- Path=/withapitimeout/**
filters:
- Hystrix=apiTimeOut
- RewritePath=/withapitimeout/(?<segment>.*), /appname/posts/$\{segment}
# Global Timeout Configuration
#hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds: 30000
# Application Level Timeout Configuration
hystrix.command.appTimeOut.execution.isolation.thread.timeoutInMilliseconds: 30000
# API Level Timeout Configuration
hystrix.command.apiTimeOut.execution.isolation.thread.timeoutInMilliseconds: 15000
Now the application level timeout and the api level timeout is working fine, But I am not getting any way to define the Global Timeout filter. Documentation for the same is yet not available:
https://github.com/spring-cloud/spring-cloud-gateway/blob/master/docs/src/main/asciidoc/spring-cloud-gateway.adoc#combined-global-filter-and-gatewayfilter-ordering
Any Idea how to do this?

spring-cloud-gateway RewritePath GatewayFilter not working

I am developing an spring-cloud-gateway application. Where I am using a RewritePath GatewayFilter for processing some pathvariable. Following is my downstream api running on port 80.
#GetMapping("/appname/event/{eventId}")
public Mono<ResponseEntity> getEventTimeOutWithPathVariable(
#RequestHeader(name = "customerId") UUID customerId,
#PathVariable(name = "eventId") String eventId) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("customerId", customerId);
map.put("eventId", eventId);
return Mono.just(new ResponseEntity(map, HttpStatus.OK));
}
And in My gateway application the filter configs are given as:
- id: api_timeout_route
uri: http://localhost/appname/event/
predicates:
- Path=/withapitimeout/**
filters:
- Hystrix=apiTimeOut
- RewritePath=/withapitimeout/(?<segment>.*), /$\{segment}
But it is not working . what I am doing wrong? I am getting the following log.
Mapping [Exchange: GET http://localhost:8000/withapitimeout/306ac5d0-b6d8-4f78-bde8-c470478ed1b1]
to Route{id='api_timeout_route', uri=http://localhost:80/appname/event/
Mainly the path variable is not getting re-written. any help?
I'm not an expert but you can try something like this:
- id: api_timeout_route
uri: http://localhost
predicates:
- Path=/withapitimeout/**
filters:
- Hystrix=apiTimeOut
- RewritePath=/withapitimeout/(?<segment>.*), /appname/event/$\{segment}
Let me know ;)

Spring Cloud Feign report 404

I use Eureka to register a service and use Feign to discover services, but if I don't add URL parameters, the system will report 404 exceptions.
And my code id below that does not work :
#FeignClient(name = "CRAWLER-SERVICE")
And Below code works :
#FeignClient(name = "crawler-service", url = "http://192.168.199.229:8091/crawler")
Stack trace :
feign.FeignException: status 404 reading CrawlerServiceApi#queryAllConditions(String,String)
at feign.FeignException.errorStatus(FeignException.java:62) ~[feign-core-9.5.0.jar:na]
at feign.codec.ErrorDecoder$Default.decode(ErrorDecoder.java:91) ~[feign-core-9.5.0.jar:na]
at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:138) ~[feign-core-9.5.0.jar:na]
at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:76) ~[feign-core-9.5.0.jar:na]
at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:103) ~[feign-core-9.5.0.jar:na]
at com.sun.proxy.$Proxy120.queryAllConditions(Unknown Source) ~[na:na]
at com.gezizhi.boss.controller.CrawlerConditionController.queryAllSource(CrawlerConditionController.java:29) ~[classes/:na]
at com.gezizhi.boss.controller.CrawlerConditionController$$FastClassBySpringCGLIB$$bd843b81.invoke(<generated>) ~[classes/:na]
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) ~[spring-core-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738) ~[spring-aop-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) [spring-aop-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:85) ~[spring-aop-4.3.13.RELEASE.jar:4.3.13.RELEASE]
The eureka configuration is:
server:
port: 8761
eureka:
instance:
hostname: localhost
client:
register-with-eureka: false
fetch-registry: false
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
server:
enable-self-preservation: false
wait-time-in-ms-when-sync-empty: 0
And the client configuration is:
eureka:
instance:
lease-expiration-duration-in-seconds: 2
lease-renewal-interval-in-seconds: 1
client:
serviceUrl:
defaultZone: http://127.0.0.1:8761/eureka/
The server code:
#RestController
#RequestMapping("/api/crawler")
public class CrawlerConditonApi {
private final CrawlerConditonService crawlerConditonService;
#Autowired
public CrawlerConditonApi(CrawlerConditonService crawlerConditonService) {
this.crawlerConditonService = crawlerConditonService;
}
#GetMapping("/conditions")
public String queryAllConditions(String belongDatasource, String conditionStatus) {
return crawlerConditonService.queryAllCondition(belongDatasource, conditionStatus);
}
#PostMapping("/conditions")
public String insertConditon(String params, String belongDatasource) {
return crawlerConditonService.insertConditon(params, belongDatasource);
}
#PutMapping("/conditions/{id}/status/{status}")
public String updateCondition(#PathVariable("id") String id, #PathVariable("status") String status) {
return crawlerConditonService.updateCondition(id, status);
}
}
THE CLIENT CODE:
#FeignClient(name = "CRAWLER-SERVICE")
public interface CrawlerServiceApi {
#RequestMapping(value = "/api/papersources/", method = RequestMethod.GET)
String queryAllSource();
#RequestMapping(value = "/api/papersources/{id}/status/{status}", method = RequestMethod.PUT)
String updateSource(#PathVariable("id") String id, #PathVariable("status") String status);
#RequestMapping(value = "/api/crawler/conditions", method = RequestMethod.GET)
String queryAllConditions(#RequestParam("belongDatasource") String belongDatasource,
#RequestParam("conditionStatus") String conditionStatus);
#RequestMapping(value = "/api/crawler/conditions", method = RequestMethod.POST)
String insertConditon(#RequestParam("params") String params,
#RequestParam("belongDatasource") String belongDatasource);
#RequestMapping(value = "/api/crawler/conditions/{id}/status/{status}", method = RequestMethod.PUT)
String updateCondition(#PathVariable("id") String id, #PathVariable("status") String status);
}
And I use in Controller:
#RestController
public class CrawlerConditionController {
private final CrawlerServiceApi crawlerServiceApi;
#Autowired
public CrawlerConditionController(CrawlerServiceApi crawlerServiceApi) {
this.crawlerServiceApi = crawlerServiceApi;
}
#GetMapping("/conditions/query")
public AbstractResult queryAllSource(#RequestParam("belongDatasource") String belongDatasource,
#RequestParam("conditionStatus") String conditionStatus) {
return ApiInvokeRspUtil.returnDataRowsInvokeRsp("CRL00000",
crawlerServiceApi.queryAllConditions(belongDatasource, conditionStatus));
}
#PostMapping("/conditions/add")
public AbstractResult addConditon(#RequestParam("paramJson") String paramJson,
#RequestParam("belongDataSource") String belongDataSource) {
return ApiInvokeRspUtil.returnDataRowsInvokeRsp("CRL00000",
crawlerServiceApi.insertConditon(paramJson, belongDataSource));
}
#PostMapping("/conditions/{id}/status/{status}")
public AbstractResult updateConditon(#PathVariable("id") String id,
#PathVariable("status") String status) {
return ApiInvokeRspUtil.returnDataRowsInvokeRsp("CRL00000",
crawlerServiceApi.updateCondition(id, status));
}
}
application.yml which contain CrawlerConditonApi's project
server:
context-path: /crawler
port: 8091
eureka:
instance:
lease-expiration-duration-in-seconds: 2
lease-renewal-interval-in-seconds: 1
client:
serviceUrl:
defaultZone: http://127.0.0.1:8761/eureka/
spring:
datasource:
driver-class-name: org.mariadb.jdbc.Driver
url: jdbc:mysql://localhost:3306/gezizhi?useUnicode=true&characterEncoding=utf-8
username: root
password: password
initialSize: 5
minIdle: 5
maxActive: 20
maxWait: 60000
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
poolPreparedStatements: true
maxPoolPreparedStatementPerConnectionSize: 20
filters: stat,wall,log4j
connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
redis:
database: 0
host: 127.0.0.1
port: 6379
password: password
pool:
max-idle: 10
max-wait: 10000
max-active: 1024
min-idle: 1
timeout: 3000
application:
name: crawler-service
mybatis:
type-aliases-package: com.gezizhi.crawler.dao.domain
mapper-locations: classpath:mybatis/*.xml
It's an old question, still posting my answer so it may help someone else as I had the same problem and finally was able to solve it.
It happened due to server.context which is set to crawler. Since this effectively adds a new url segment, you need to change your feign client to below (mind the context added after service name)
#FeignClient(name = "CRAWLER-SERVICE/crawler")
Or you need to change the RequestMapping to something like below (again mind the context added before service url):
#RequestMapping("crawler/<rest of the url>")

Resources