我有两个名为simple-core-impl和的项目simple-core-web。这两个项目都是,spring based并且都具有一个父项目名称simple-core。我simple-impl-config.xml在simple-core-impl项目simple-web-config.xml中simple-impl-config.xml。我有一个具有类的bean:simple service它具有一个向我返回消息“ hello World”的方法。我想在中导入simple-impl-config.xml,simple-web-config.xml以便Bean可以在simple-core-web项目中的控制器中使用。simple-core-web项目中有一个jar simple-core-impl项目。因此,请告诉我如何将spring-config.xml一个项目导入spring-config.xml另一个项目,以便只需导入即可将first的所有bean导入另一个项目?我不想重写所有bean。
3 回答

ITMISS
TA贡献1871条经验 获得超8个赞
您必须在模块A中添加模块B的jar / war,并在新的spring-module文件中添加类路径。只需添加此行
spring-moduleA.xml-是模块A中资源文件夹下的文件。通过添加此行,它将所有bean定义从模块A导入到模块B。
模块B / spring-moduleB.xml
import resource="classpath:spring-moduleA.xml"/>
<bean id="helloBeanB" class="basic.HelloWorldB">
<property name="name" value="BMVNPrj" />
</bean>

慕容708150
TA贡献1831条经验 获得超4个赞
由于某些原因,里卡多建议的导入对我没有用。我得到它与以下声明一起工作:
<import resource="classpath*:/spring-config.xml" />
添加回答
举报
0/150
提交
取消