DEV Community

Discussion on: New Web Framework?

 
cjbrooks12 profile image
Casey Brooks

I'm not too familiar with Spring Boot, but code-gen would make the compilation step take longer, not the server startup. Java code generation libraries (such as Dagger and Butterknife which are common on Android) actually dramatically increase application startup times, because all the hard work has been done at compile-time.

Taking Dagger as an example (dependency injection), the generated code doesn't require Reflection as a runtime-library would. It looks for @Inject annotations in your code, finds the @Modules which provide those dependencies, and writes new Java source files to create the object for you. Super fast, no reflection required. Spring Boot does runtime injection, and so uses Reflection to find the @Inject/@Autowired annotations, and then uses Reflection to call the constructor or set the fields as necessary, which is known to be slow. This is in addition to the many other things Spring is doing on server startup (classloading, resolving routes, connecting to databases, etc.).

Thread Thread
 
stealthmusic profile image
Jan Wedel

A spring boot app with 1000s of beans and component scanning still starts in 1-2 seconds. Most of the startup time is consumed when using Hibernate and flyway eg.