0

Trying to use the different configuration files based on the environment. For example

In the dev environment, I have the below file

application-dev.yml

micronaut:
  security:
    enabled: true
    token:
      jwt:
        enabled: true
        signatures:
          jwks:
            IdentityServer:
              url: 'https://localhost:5001/.well-known/openid-configuration/jwks'

For another environment, I have the below configuration

application.yml

micronaut:
  application:
    name: feteBirdApigateway
  server:
    port: 8080
    cors:
      enabled: true
  security:
    enabled: true
    token:
      jwt:
        enabled: true
        signatures:
          jwks:
            IdentityServer:
              url: 'https://falconidentityserver.azurewebsites.net/.well-known/openid-configuration/jwks'

Now when I am running the application in intellj, the application is using the file applicaiton.yml. It should pick up the application-dev.yml and value url: 'https://localhost:5001/.well-known/openid-configuration/jwks' but it is picking the value from application.yml. However, it should pick only that value from dev file and all the other values should be picked from application.yml

As per the micronaut documentation https://docs.micronaut.io/latest/guide/index.html#environments I need to setup micronaut.environments

When I am running the application in the local machine, shouldn't it picked the application-dev.yml. How can I setup the environment

San Jaisy
  • 15,327
  • 34
  • 171
  • 290

2 Answers2

0

I'm not sure if it's supposed to select "dev" automatically when running from an IDE. But, you can override the environment by passing these two JVM variables in your IntelliJ Run/Debug configuration:

-Dmicronaut.environments=dev
-Dmicronaut.env.deduction=false
TrogDor
  • 984
  • 6
  • 14
0

Setting the default environment in the main method

public class ApiGatewayApplication {

    public static void main(String[] args) {
        Micronaut.build((String[]) null).defaultEnvironments("dev").start();
    }
}

Reference - https://github.com/micronaut-projects/micronaut-core/issues/2417

San Jaisy
  • 15,327
  • 34
  • 171
  • 290