How to fail at startup if the base-url of a HTTP service client in Spring Boot 4 is not set?
04:01 27 Nov 2025

With Spring Boot 3, I created a @ConfigurationProperties record with @NotBlank validation to manually set the base URL on the RestClient that is passed to the HttpServiceProxyFactory For example:

@Validated
@ConfigurationProperties(prefix = "myapp")
public record MyAppProperties(@NotBlank String myRemoteApiBaseUrl){}

With the Spring Boot 4 HTTP Service Client, there is no need anymore to manually create the RestClient and HttpServiceProxyFactory. The recommended way is to set the base url via:

spring:
  http:
    serviceclient:
      my-remote-api:
        base-url: 'https://www.my-remote-api'

However, if the base-url is not set, the application will not be able to make the remote call and an IllegalArgumentException is thrown when a call is actually tried. I would like to have the application already fail at startup when the base-url was forgotten to be configured.

java spring spring-boot