BadPractice7 - SpotBugsExtensionForSpringFrameWork/CS5098 GitHub Wiki
Bug Name: Use ApplicationContext over BeanFactory
Description
Author - "it's always preferable to use ApplicationContext when building complex enterprise applications." Reason1: ApplicationContext enhances BeanFactory in a more framework-oriented style and provides several features that are suitable for enterprise applications. For instance, it provides messaging (i18n or internationalization) functionality, event publication functionality, annotation-based dependency injection, and easy integration with Spring AOP features. i.e., more features. Reason2: BeanFactory only supports two scopes, Singleton and Prototype. Reason3: The ApplicationContext automatically registers BeanFactoryPostProcessor and BeanPostProcessor at startup. On the other hand, the BeanFactory does not register these interfaces automatically. Spring 2.0 (and above) heavily uses BeanPostProcessor. BeanFactory = Lazy Loading ApplicationContext = Eager Loading
Reference List
https://www.baeldung.com/spring-beanfactory-vs-applicationcontext https://stackoverflow.com/questions/243385/beanfactory-vs-applicationcontext