I am just curious to know when a Spring.xml file loaded into application multiple times into an application using ClassPathXmlApplicationContext. For example if I want to get the services defined in Spring.xml into my claases by creating new instance of ApplicationContext in each class . Does this approach create each time new beans without destroying the previously created beans?Does this creates any memory problems ? When I see in ClassPathXmlApplicationContext API in spring website I found this.Does this refresh creates new bean definition of existing bean by destroying existed one?
ClassPathXmlApplicationContext(String... configLocations)
***Create a new ClassPathXmlApplicationContext, loading the definitions from the given XML files and automatically refreshing the context.***
When the same xml file is loaded several times spring creates the same beans several times. In most cases this does not cause problems except initiation time. But sometimes you can get conflicts. For example if you have bean that is listening to TCP port and then open yet another bean that tries to connect to the same port it fails.