question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

spring.config.import configuration clashes with spring.cloud.config.enabled

See original GitHub issue

Observed behaviour

A spring.config.import config property is set to optional:configserver:http://myconfigserver:5656 in a main configuration file application.properties. In the application-dev.properties config file, the property spring.cloud.config.enabled is set to false, since we don’t require any property to be loaded from the remote config server on the dev profile. However, the observed behavior is that ConfigServerConfigDataLoader implementation doesn’t take into account that setting and is going to try to pull that configuration from the remote server. If the connection fails, it will check for the fail-fast and isOptional flags and make a decision based on that outcome.

Intended behavior

If the spring.cloud.config.enabled property is set to false, ConfigServerConfigDataLoader should not even try to connect to the remote server and return as soon as possible.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:5
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

9reactions
roookeeecommented, Oct 28, 2021

Leaving my stackoverflow answer here in case someone stumbles into this issue via google: https://stackoverflow.com/questions/68702479/disable-config-service-client-activated-with-spring-config-import-in-springboott/69739888#69739888

There are workarounds but the situation of spring.config.import not being overridable, Spring Cloud Config requiring at least one spring.config.import to start with configserver: when it’s enabled and Splring Cloud Config removing it’s PropertySourceLoader for configserver: prefixed spring.config.import entries when disabled makes this very cumbersome.

I for one would wish that Spring Cloud Config would still register its PropertySourceLoader when disabled and just make it a noop. This way no fancy shenanigans (like linked above) are needed - especially when these fancy workarounds break apart because Spring Cloud Configs check for “at least one spring.cloud.config entry must start with configserver:” is not resolving variable placeholders when doing this check:

some.workaround = configserver:localhost:1337
spring.config.import = ${some.workaround}

This is not working because of the aformentioned missing variable resolution. This issue is creating a lot of headaches for our production environment at the moment.

0reactions
mplaincommented, Sep 7, 2021

Just spent two days trying to figure out why the dockerfile command line argument does not override spring.config.import specified in application.properties.

spencergibb
all spring.config.import entries are evaluated. They do not behave like normal properties that can be overridden. 

this migration has been very painful =_=

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring Cloud Config Server
If you use Spring Cloud Config Client, you need to set the spring.config.import property in order to bind to Config Server. You can...
Read more >
No spring.config.import property has been defined
Importing configuration since Spring Boot 2.4 is done by spring.config.import ... spring: cloud: config: import-check: enabled: false.
Read more >
Configure your managed Spring Cloud Config Server in Azure ...
Learn how to configure a managed Spring Cloud Config Server in Azure Spring Apps on the Azure portal.
Read more >
Quick Intro to Spring Cloud Configuration - Baeldung
Tip: If we're planning to use multiple config server instances pointing to the same config repository, we can configure the server to clone...
Read more >
Spring Cloud Config Server - YouTube
In this session, we are going to discuss managing externalized configuration in a distributed system which was a challenge but ' Spring Cloud...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found