Because I define Qurtzs in the configuration. I think If I read configure twice, the quartz will start twice. But it didn't. The application seem to work normally. So I want to confirm that I can read Spring configuration not only once any where in my appliction. right?
What do you mean by �reading the configuration twice�? As far as I know you use the appropriate implementation of the ApplicationContext and allow the container to load the configuration and initialize the bean factory. This will happen only once after initializing the context. Something like this:
In a web application you have to configure the context listener in your web.xml file (or use a specific servlet with load on startup = 1):
And again is the container that loads the configurations. My point here is that the container should be the one loading the configuration files and initializing the bean factory. Could you detail what do you mean by loading or reading the configuration twice? Regards.
Hi Tanase : Thanks for your reply. The meaning of reading Spring configuration twice is like following code
I use ClassPathXmlApplicationContext to read xml configuration twice. It seem no error in the log. So I want to confirm taht I can load Spring configuration not only once and Spring container will still work normally.
Here there is my two cents bet: the ClassPathXmlApplicationContext also implements the BeanFactory interface. This makes the point that after initializing the app context this class will also load all beans from the configuration file(s). By default these beans suppose to be singletons (unless you specify otherwise). I would say that you�d have two different bean factories instances, loading the same beans. Just for the argument sake you can try running this code:
Where "beanName" is the name of one of your beans as it appears in the config file. This should also be loaded as a singleton (default).
And again just for the argument sake: I personally could not see any treason or benefit from having two different bean factories.