Philipp Claßen Philipp Claßen - 27 days ago 16
Java Question

Fail fast if a Spring application cannot connect to its config server

Consider you have a Spring application that gets its configuration from a config server. If it cannot connect to the config server, the application will continue to start but as all configurations are missing, it will eventually fail with a potentially misleading error.

Is it possible to configure Spring, so it immediately aborts when it cannot connect to its config server during startup?

Answer

Set spring.cloud.config.failFast to true in your bootstrap.yml or bootstrap.properties file.

From the documentation

Config Client Fail Fast

In some cases, it may be desirable to fail startup of a service if it cannot connect to the Config Server. If this is the desired behavior, set the bootstrap configuration property spring.cloud.config.failFast=true and the client will halt with an Exception.