Default Environment

Micronaut supports the concept of one or many default environments. A default environment is one that is only applied if no other environments are explicitly specified or deduced. Environments can be explicitly specified either through the application context builder Micronaut.build().environments(…​), through the micronaut.environments system property, or the MICRONAUT_ENVIRONMENTS environment variable. Environments can be deduced to automatically apply the environment appropriate for cloud deployments. If an environment is found through any of the above means, the default environment will not be applied.

To set the default environments, modify your application main method:

  1. public static void main(String[] args) {
  2. Micronaut.build(args)
  3. .mainClass(Application.class)
  4. .defaultEnvironments("dev")
  5. .start();
  6. }