猿问

如何将一个项目的spring-config.xml导入另一个项目的spring-config

我有两个名为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。


胡说叔叔
浏览 716回答 3
3回答

ITMISS

您必须在模块A中添加模块B的jar / war,并在新的spring-module文件中添加类路径。只需添加此行spring-moduleA.xml-是模块A中资源文件夹下的文件。通过添加此行,它将所有bean定义从模块A导入到模块B。模块B / spring-moduleB.xmlimport resource="classpath:spring-moduleA.xml"/><bean id="helloBeanB" class="basic.HelloWorldB">&nbsp; <property name="name" value="BMVNPrj" /></bean>

慕容708150

由于某些原因,里卡多建议的导入对我没有用。我得到它与以下声明一起工作:<import resource="classpath*:/spring-config.xml" />
随时随地看视频慕课网APP

相关分类

Java
我要回答