【发布时间】:2012-05-18 04:14:40
【问题描述】:
我的项目由多个 Spring 子项目组成:
- 服务1
- 服务2
- 服务3
每个 Service 对内部的其他 Bean 都有多个依赖项,因此每个 Service 都有一个 applicationContext.xml 将 Service 连接在一起。
我将每个子项目都制作为独立的 maven 构建,我认为我可以创建一个 AllServicesTogether 应用程序来将这些服务{1..3} 连接在一起。
这通过向这些服务添加 maven 依赖项来工作。
<dependencies>
<dependency>
<groupId>org.myproject</groupId>
<artifactId>myproject-service{1..3}</artifactId>
<version>0.1-SNAPSHOT</version>
</dependency>
...
</dependencies>
但是在 AllServicesTogether 应用程序中,所有子服务的连接都丢失了。我猜 Subservices 不是用 Subservice ApplicationContext 编译的,而是使用 AllServicesTogether ApplicationContext。
这个想法是封装 SubSerivces 的所有接线,并使用以下方法简单地连接 AllServicesTogether:
<beans ..>
<bean class="org.myproject.service1.Service1"/>
<bean class="org.myproject.service1.Service2"/>
<bean class="org.myproject.service1.Service3"/>
</beans>
我从花费数小时的较大项目中创建了这些子项目。 是否可以使用这种接线方法,还是我需要包含所有这些服务中的 context.xml?
【问题讨论】:
标签: java xml spring maven applicationcontext