I am using spring cloud to route application but unable to do so below are the details
Gateway configuration
port: 8080
debug: true
spring:
application:
name: cloud-gateway
cloud:
gateway:
discovery:
locator:
enabled: true
lower-case-senstive: true
routes:
- id: product-composite
uri: localhost:7000
predicates:
- Path: /product-composite/**
eureka:
instance:
hostname: localhost
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
server:
port: 8761
waitTimeInMsWhenSyncEmpty: 0
response-cache-update-interval: 5000
management.endpoints.web.exposure.include: '*'
Product Composite Service* (I am trying to call)
port: 7000
spring:
application:
name: product-composite
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
initialInstanceInfoReplicationIntervalSeconds: 5
registryFetchIntervalSeconds: 5
register-with-eureka: true
fetch-registery: true
instance:
leaseRenewalIntervalInSeconds: 5
leaseExpirationDurationInSeconds: 5
Path
@RestController
public class ProductCompositeServiceController {
@GetMapping
public String getString() {
return "Hello grom product CompositeController";
}
}
Can you help? If needed I can provide more details
Note: if product-composite-servcie is called without eureka I am getting response but with eureka I am getting
404 Resource not found
Edit Below is the stacktrace I am getting so far:
2020-06-24 22:22:05.252 DEBUG 38876 --- [or-http-epoll-2] o.s.w.r.handler.SimpleUrlHandlerMapping : [63939523-1] Mapped to ResourceWebHandler ["classpath:/META-INF/resources/", "classpath:/resources/", "classpath:/static/", "classpath:/public/"]
2020-06-24 22:22:05.255 DEBUG 38876 --- [or-http-epoll-2] o.s.w.r.resource.ResourceWebHandler : [63939523-1] Resource not found
2020-06-24 22:22:05.273 DEBUG 38876 --- [or-http-epoll-2] a.w.r.e.AbstractErrorWebExceptionHandler : [63939523-1] Resolved [ResponseStatusException: 404 NOT_FOUND] for HTTP GET /product-composite/
2020-06-24 22:22:05.281 DEBUG 38876 --- [or-http-epoll-2] o.s.http.codec.json.Jackson2JsonEncoder : [63939523-1] Encoding [{timestamp=Wed Jun 24 22:22:05 IST 2020, path=/product-composite/, status=404, error=Not Found, mess (truncated)...]
2020-06-24 22:22:05.299 DEBUG 38876 --- [or-http-epoll-2] o.s.w.s.adapter.HttpWebHandlerAdapter : [63939523-1] Completed 404 NOT_FOUND
I also tried to add path as
routes:
- id: product-composite
uri: localhost:7000
predicates:
- Path: /product-composite/**
filters:
- RewritePath: /product-composite/(?<segment>.*), /$\{segment}
StripPath,SetPathorRewritePath. - spencergibbspring.webflux.base-path=product-compositeto product-composite-service solved my problem - emotionlessbananas