Regarding multiple dispatcher servlet in Spring
I have two dispatcher servlets in my application. I write database related config (sessionfactory etc.) in separate xml file. In each dispatcher servlet config file (abc-servlet.xml, xyz-servlet.xml) I import this common database file. I am wondering will Spring create two instances of sessionFactory or is it shared with both. Both application are working fine in my dev environmen开发者_StackOverflow中文版t. I am worried about production if this causes any memory related issues.
From DispatcherServlet doc:
A web application can define any number of DispatcherServlets. Each servlet will operate in its own namespace, loading its own application context with mappings, handlers, etc. Only the root application context as loaded by ContextLoaderListener, if any, will be shared.
So, you're sessionFactory will only be shared if it's defined in an app context loaded by the ContextLoaderListener, otherwise not.
精彩评论