Enabling Distributed Configuration with Consul

Using the CLI

If you create your project using the Micronaut CLI, supply the config-consul feature to enable Consul’s distributed configuration in your project:

  1. $ mn create-app my-app features config-consul

To enable distributed configuration, similar to Spring Boot and Grails, create a src/main/resources/bootstrap.yml configuration file to configure Consul, and enable the configuration client:

bootstrap.yml

  1. micronaut:
  2. application:
  3. name: hello-world
  4. config-client:
  5. enabled: true
  6. consul:
  7. client:
  8. defaultZone: "${CONSUL_HOST:localhost}:${CONSUL_PORT:8500}"

After enabling distributed configuration, store the configuration to share in Consul’s key/value store. There are a number of ways to do that.