Search code examples
javaspringspring-bootreloadnetflix-zuul

How to config routes in Spring Cloud Zuul


In Spring Cloud Zuul server we can define all routes which need be redirected via "application.properties".

For example:

zuul.routes.resource.path=/api/**
zuul.routes.resource.url=http://api.com:9025

Once the fat jar is created the "application.properties" is encapsulated into jar, and it's not possible to edit and reload the rules inside the file.

Is there any to inform Zuul about the routes in an external file, and at the same time reload them without stopping the server?


Solution

  • ...a bit late to the party, but...

    You can do all that you want with the ConfigServer!

    1. Create an application.yml for config that is common across ALL applications
    2. Create profile specific application-mycommonprofile.yml. As 1. but for the 'mycommonprofile' profile.
    3. Create an appX.yml for each application that is specific to that application.
    4. Create profile specific appX-myprofile.yml. As 3. but for the 'myprofile' profile.

    All of these files are optional and are not dependent on any others. You can have an application-mycommonprofile.yml without an application.yml for example.

    Hope that helps!