How should each class in an application retrieve the Spring application context? Or, stated another way, how many times should an application invoke new ClassPathXmlApplicationContext("applicationContext.xml")?
How should each class in an application retrieve the Spring application context? Or, stated
Share
Usually a class does not need the application context, but it needs some of the objects Spring injects. And this is configured in that applicationContext.
As such an application typically calls
new ClassPathXmlApplicationContext("applicationContext.xml")only once.