1

I would like to create a shared library which provides default configuration to all my spring-boot web application clients. So far I was successfully able to create default actuator configuration using this SO answer. However, I'd like to provide the following three configurations:

spring.cloud.config.discovery.enabled=true
spring.cloud.config.discovery.service-id=MY-CLOUD-CONFIG-SERVER
spring.cloud.config.fail-fast=true

The clients are also successfully connecting to eureka and the config-server is up and running.

I have the following setup, that works for the actuator default config:

com.livanov.test.DefaultActuatorConfiguration.java

@PropertySource("classpath:default-actuator.properties")
public class DefaultActuatorConfiguration {

}

META-INF/spring.factories

org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
  com.livanov.test.DefaultActuatorConfiguration

When I do the same class for the spring.cloud.config.* properties it doesn't work. I also tried to bind them in spring.factories with the org.springframework.cloud.bootstrap.BootstrapConfiguration marker, but that doesn't work either. The clients in any of those setups are trying to connect to the default 8888 port of cloud-config. Probably I am missing what is the sequence of actions of the spring auto-configuration.

I also tried adding

@Order(Integer.MIN_VALUE)

and

@AutoConfigureBefore({
    ConfigServiceBootstrapConfiguration.class,
    DiscoveryClientConfigServiceBootstrapConfiguration.class
})

but those both look like hacks and actually don't work.

LIvanov
  • 1,126
  • 12
  • 30

0 Answers0