spring.config.import fail over

Viewed 190

I have a Springboot 2.4 application that is trying to run a test in a CD/CI environment without access to the configuration server specified in application.properties file.

I tried to provide alternative configurations for the missing values in a profile specific properties file.

Whenever the test starts to run, it seems that is trying to setup the spring context before loading the profile specific configuration and the test fails with a java.lang.IllegalStateException: Failed to load ApplicationContext exception because it doesn't have a property provided in the profile specific properties file.

Is there any workaround for this?

1 Answers

I encountered the same issue when loading config from AWS secret manager.

You have to add it to a profile section in the main application.properties file, not a profile specific one.

# Global section
test.value1=foo

#---
spring.config.activate.on-profile=configserver
spring.config.import=configserver:http://myconfigserver.com

Only if you run the app using the configserver profile (where the config server is reachable) will it attempt to load config from it.

Related