Quoting wilkinsona's comment at https://github.com/spring-projects/spring-boot/issues/38185#issuecomment-1792128910:

Thanks for the sample and for trying the RC. This is a regression in Spring Security 6.2, caused by the changes made for https://github.com/spring-projects/spring-security/issues/11783. Please open a Spring Security issue.

It looks like https://github.com/spring-projects/spring-boot/issues/38185 is caused by a bug in Spring Security. Since I also came across it in my project, I took the chance to create the ticket here as suggested.

I'm also quoting the sample POC for convenience:

https://github.com/simon-hock/spring-security-aot

Comment From: simon-hock

Thanks for posting here @meletis ! I was about to do it !

Have a great day

Comment From: sjohnr

Thanks for trying the RC and for the report @meletis! I can confirm that we're using a singleton supplier as I didn't realize that would not work with AOT. We'll take a look right away.

Comment From: sjohnr

Thanks again @meletis for the report and @simon-hock for the sample. I have pushed a fix and verified that an AOT build succeeds. Would either of you be able to try out 6.2.0-SNAPSHOT and let me know if it fully resolves the issue for you?

Comment From: meletis

It worked great for me @sjohnr !

Thanks again!