上QQ阅读APP看书,第一时间看更新
Lazy loading versus preloading
Lazy loading ensures that beans are loaded on the fly when requested, and preloading ensures the beans are loaded before they are used. The Spring IoC container uses preloading by default. So, loading all classes at the start even if they're not used would not be a wise decision because some Java instances would be highly resource-consuming. We should use the required methodology based on the application requirement.
If we need to load our application as fast as possible, then go for lazy loading. If we need our application to run as fast as possible and serve a client request faster, then go for preloading.