1
votes

I met similar questions on different posts, but they are useless for me (no answer or no helpful answer). I'm going describe all details here and hope for help.

I use java8, spring boot 2.0.3, spring cloud elements are based on Finchley.RELEASE version.

In my test micro services application I have next services: config-server, discovery-service (Eureka), edge-service (zuul), card-service. All services loads at start time their own configuration from configuration-server. Services are started without issues.

card-service - gets random port at start time. This is a reason of configuring zuul rout to calendar-service by serviceId.

zuul:
  debug:
    request: true
  routes:
    card-service:
        path: /card-service/**
        serviceId: card-service
        stripPrefix: true

Using discovery-service client I detected next registered services ["edge-server", "card-service"]. So zuul route uses same serviceId (card-service). The service name is correct because it is the same in card-service app bootstrap.yml:

spring:
  application:
    name: card-service

I use direct access to card-service by:

http://localhost:59496/card-service/api/cards

http://localhost:59496/api/cards

(i configured same result for it). - works fine.

My Zuul (edge-server is started on 8765 port) so I expect navigation by

http://localhost:8765/card-service/api/cards

gives same result. But result is empty. Checking edge-server logs:

No handler mapping found for [/card-service/api/cards]
Last-Modified value for [/card-service/api/cards] is: -1

Check via actuator mappings for edge-server (http://localhost:8765/actuator/mappings - I've demonstrated here most interested part):

{
  "contexts": {
    "edge-server-1": {
      "mappings": {
        "dispatcherServlets": {
          "dispatcherServlet": [
            ...,
            {
              "handler": "org.springframework.cloud.netflix.zuul.web.ZuulController@24a37416",
              "predicate": "/card-service/**",
              "details": null
            },

Question

Is any idea how to fix route mapping for zuul?

1
The indentation of zull.routes.card-service is wrong. check zuulproperties section of :8765/configprops if correct.Addo Zhang

1 Answers

6
votes

It was my fail. I thought I have configured it following tutorial, but seems autocomplete used @EnableZuulServer instead of @EnableZuulProxy in spring boot configurations. @EnableZuulProxy need to load configured routes for Zuul and everything works correctly than.