Piyush Tyagi
Piyush Tyagi

Reputation: 125

config property not getting picked in micronaut

I have tried to create the environment specific configuration in micronaut

with main application.yml as

micronaut:
    application:
        name: xyz
    server:
        port: 9090
    environments: local

and local configuration file as with name as application-local.yml

xyz:
  aws:
    accessKey: <access_key>
    secretKey: <secret_key>

In code I am trying to access as

@Value("${xyz.aws.accessKey}")

I while trying to access them in code getting following error

Message: Error resolving field value [${xyz.aws.accessKey}]. Property doesn't exist or cannot be converted

Upvotes: 3

Views: 4041

Answers (1)

Piyush Tyagi
Piyush Tyagi

Reputation: 125

I found out that there is no such properties in micronaut similar to spring's

spring.profiles.active

here instead we have to pass the external file as VM options instead

-Dmicronaut.environments=local

then it started to work

Upvotes: 1

Related Questions