Tarun Pande
Tarun Pande

Reputation: 401

Spring Cloud Config Client not able to resolve placeholder

I am facing an issue while trying to start Config Client with the below dependency:

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-config</artifactId>
    </dependency>

The placeholder i am trying to get is the Environment variable which will help me pick up the files from config server. E.g config-client-{ENVIRONMENT}.properties

Exception: java.lang.IllegalStateException: Failed to load ApplicationContext Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'ENVIRONMENT' in value "${ENVIRONMENT}"

Upvotes: 0

Views: 447

Answers (1)

Sushil Behera
Sushil Behera

Reputation: 981

In Spring Boot ${ENVIRONMENT} does not come out of box.

You have two options.

  1. Set ENVIRONMENT= in all application.yml files. So you can get it at run time.

  2. Fetch the file config-client-${spring.profiles.active}.properties so it will get the property file as per the spring profile.

Upvotes: 1

Related Questions