Bean definitions with instance supplier callbacks can't be supported by design on AOT as explained in spring-projects/spring-framework#29555. Spring Framework is going to document this and throw an exception during AOT processing of such bean via spring-projects/spring-framework#29556 instead of silently ignoring the instance supplier when a default constructor on the bean class is found.

While working on changing that behavior, I noticed a few Spring Boot beans are defining instance suppliers (there may be other ones, this is just on a simple app): - org.springframework.boot.context.properties.BoundConfigurationProperties - org.springframework.boot.web.server.WebServerFactoryCustomizerBeanPostProcessor - org.springframework.boot.web.server.ErrorPageRegistrarBeanPostProcessor It currently works because the instance supplier references the bean class default constructor and because Spring Framework silently ignores them, but we would like to report proper error to the user when that's the case.

Could you please update Spring Boot codebase to remove the few usages of bean instance suppliers? I will also check the other project portfolio via the AOT smoke tests and reach the related teams.

Comment From: sdeleuze

org.springframework.boot.context.properties.ConfigurationPropertiesBinder is using a customized instance supplier here, not sure if that's currently handled on AOT side or just silently ignored for now.

Comment From: mhalbritter

I found these places where we use an instance supplier:

  • org.springframework.boot.autoconfigure.webservices.WebServicesAutoConfiguration.WsdlDefinitionBeanFactoryPostProcessor#registerBeans
  • org.springframework.boot.context.properties.BoundConfigurationProperties#register
  • org.springframework.boot.autoconfigure.web.reactive.ReactiveWebServerFactoryAutoConfiguration.BeanPostProcessorsRegistrar#registerSyntheticBeanIfMissing
  • org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration.BeanPostProcessorsRegistrar#registerSyntheticBeanIfMissing
  • org.springframework.boot.context.properties.ConfigurationPropertiesBinder#register

And usages which are not used in AOT:

  • org.springframework.boot.autoconfigure.SharedMetadataReaderFactoryContextInitializer.CachingMetadataReaderFactoryPostProcessor#register
  • org.springframework.boot.context.properties.ConfigurationPropertiesBeanRegistrar#createBeanDefinition

Not 100% sure that i found them all.

Comment From: mhalbritter

I started working on it here: https://github.com/mhalbritter/spring-boot/tree/mh/33763

I'm unable to solve these usages:

And i'm not sure if this change has unintended consequences: spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBinder.java

Any help would be appreciated :)

Comment From: sdeleuze

For @ConfigurationProperties, I am not familiar with that part, but maybe this use case is already handled by ConfigurationPropertiesBeanRegistrationAotProcessor so no change is needed on that part? We can maybe do some experiment with a Boot version on top of https://github.com/spring-projects/spring-framework/commit/d9101ab48f79e133d7e18ba7a5e164d170e2e065 and check whats works and what does not.

Comment From: mhalbritter

Indeed, there are no changes needed in ConfigurationPropertiesBeanRegistrar. The SharedMetadataReaderFactoryContextInitializer doesn't need changes, too.