我是 Spring 新手,遇到的情况是单个项目包含多个模块,包括一个 Web 模块。 Web 模块使用 Spring MVC,但我想知道是否可以在项目级别拥有主要的 Spring 配置来处理整个项目,以便我可以充分利用 Spring 框架。
main
-module1
-module2
-web
+spring3.1, spring-security
这种情况下最好的设置是什么?
最佳答案
我工作的地方有这种架构。我们决定在 web 模块中使用 ContextLoaderListener(Spring Event Listener)。
然后,在 serverApplicationContext.xml 中,我们导入所有模块的上下文文件:
<import resource="classpath*:module1ApplicationContext.xml" />
<import resource="classpath*:module2ApplicationContext.xml" />
...
因此,您可以在 Web 应用程序上下文初始化期间利用 Spring 上下文加载。
关于java - 多模块项目中的spring配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8932724/