In most of our projects these days, we use the following approach to be able to bind base64 encoded files as configuration properties of org.springframework.core.io.Resource type:

@SpringBootApplication
public class MyApplication {

    public static void main(String[] args) {
        SpringApplication application = new SpringApplication(MyApplication.class);
        application.addInitializers(context -> context.addProtocolResolver(new Base64ProtocolResolver()));
        application.run(args);
    }

}

Where Base64ProtocolResolver is basically line for line identical implementation to the one recently introduced in #36033.

Upgrading to Spring Boot 3.3, expectation was we would be able to remove our homegrown Base64ProtocolResolver and boilerplate code from the application main class, but this is not possible because newly introduced Base64ProtocolResolver isn't registered with application context as protocol resolver. Additionally, Spring Boot provided Base64ProtocolResolver is (understandably) package private so it can't be reused.

Would it be possible to register Base64ProtocolResolver as protocol resolver by default?

Comment From: philwebb

I think we should do something similar to ApplicationResourceLoader and apply all protocol protocol resolvers we find via SpringFactoriesLoader.

Comment From: philwebb

Flagging to see if the team thing we should consider this a bug or and enhancement. I'm leaning enhancement to be on the safe side.

Comment From: scottfrederick

I think it should be an enhancement also.

This should fix the problem noted here, where a configuration property class with a field of type Resource does not resolve properly with a base64: resource.

Comment From: vpavic

Could you mention this in 3.4 release notes?

Comment From: philwebb

Thanks for the prod @vpavic, I've added https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.4-Release-Notes#base64-resource-support-and-automatic-protocolresolver-registration