Spring - When should you consider loading a different context into the same JVM?

I was just thinking when should I consider loading more than one application context in Spring? Everything so far I have been merging the context files with <include>

in such a way that only one application context is loaded.

Do you have any idea when you need to use more than one application context in one JVM?

+2


source to share


2 answers


If you need to use hierarchical contexts like Spring MVC . Your "web context" is loaded separately from your "main" context, so stuff defined in the "main" context (services / DAOs / etc) is available to the "web", but not vice versa.



+4


source


I almost always create a lot of Spring config files to separate the different layers of my application, but I always load them all through the same application context. The way I see it, I use Spring to "build applications" by putting together the various components of my application. Loading two different contexts doesn't make sense in my opinion. There is only one application and therefore only one context is needed. Perhaps my view is oversimplified.



0


source







All Articles