2

我只是在想,我什么时候应该真正考虑在 Spring 中加载多个应用程序上下文?到目前为止,我一直在合并上下文文件,<include>以便只加载一个应用程序上下文。

您是否知道何时在同一个 JVM 中使用多个应用程序上下文?

4

2 回答 2

4

例如,当您需要使用分层上下文时 - 就像Spring MVC一样。您的“web”上下文与您的“main”上下文分开加载,因此在“main”上下文(服务 / DAO / 等)中定义的内容可用于“web”,但反之则不行。

于 2009-09-15T17:08:51.083 回答
0

I almost always create many Spring configuration files to separate out the different layers of my application, but I always load them all via a single application context. The way I see it, I am using Spring for "application assembly", wiring together the various components of my application. Loading two different contexts, in my way of thinking, does not make sense. There is only one app, and thus only one context needed. Perhaps my view is simplistic.

于 2009-09-15T17:21:03.103 回答