Hi,
I’m running into a problem with a pretty big Spring project (about 18,000 beans). When I build with AOT processing turned on, the build crashes with:
/<_REDACTED_>/AotProcessingApplication__BeanFactoryRegistrations.java:18253: error: too many constants
public class AotProcessingApplication__BeanFactoryRegistrations {
(The generated file is massive—tens of thousands of lines.)
A couple extra details:
- The project has a huge number of Spring beans/configs.
- From what I can tell, the generated AotProcessingApplication__BeanFactoryRegistrations
file is blowing past Java’s class constant pool limit.
I searched around and found #33126, which describes a similar situation, but that seemed to be hitting method size limits rather than constant pool limits.
Here’s my setup: - Spring: 6.2.7 - Spring Boot: 3.5.0 - JDK: 21 - Build: Gradle
Is there any way to avoid hitting this limit? Can the generated BeanFactory registration file be split up, or is there a recommended workaround for big projects like this?
Right now I'm trying to break up the generated file using a Python script as a Gradle post-task, but it is pretty hacky.
Thanks a lot for any pointers!