Environment variable mapped to spring boot configuration property but in my infra(Kubernetes Cluster), the environment variable not mapped to spring boot configuration

Answered

Environment variable mapped to spring boot configuration property in intellij ,but in my infra(Kubernetes Cluster), the environment variable not mapped to spring boot configuration property.Is the IDE doing some mapping.

0
3 comments

Hi, Could you please clarify the problem? Providing some screenshots or a demo project would be helpful.

0
Avatar
Permanently deleted user

I have an application in spring boot.

I have a class  similar to the one shown below in my project.

@Configuration
@ConfigurationProperties(prefix = "client")
@Data
public class ClientConfiguration {

private Map<String, String> clientId;
}

When running in intellij, i am running it as spring boot application with with env variable specified as shown below and then spring is able to map that env variable to spring config(

client:
clientId:
eng-USA: abc123
deu-DEU: cde456

)

But the same way when i create env variable in kubernetes cluster , its not able to map that environment variable to spring boot configuration.
Change in deployment.yaml shown below:
env:
- name: CLIENT_CLIENTID_ENG-USA
   value: "abc123"

Then the environment variable is created inside the container but its not mapped to corresponding spring boot config variable.

I hope the above details would help you to understand the issue.

 

0

Hi, Are you referring to external configuration? https://docs.spring.io/spring-boot/docs/1.5.5.RELEASE/reference/html/boot-features-external-config.html#boot-features-external-config

No, it's not IDEA dependent, it's spring boot feature.

0

Please sign in to leave a comment.