简体   繁体   English

在Maven多模块项目中,如何从一个模块到另一个模块访问spring bean

[英]In a maven multi-module project, how to access the spring beans from one module to another

I have a maven multi-module application as below 我有一个Maven多模块应用程序,如下所示

parent
-+ module 1
-+ module 2
-+ module 3

Module 2 and module 3 are seperate jars and added as depencency in module 1. 模块2和模块3是独立的jar,并作为模块1的依赖添加。

All the modules have application-context assigned to it. 所有模块都分配有应用程序上下文。

I need to get the spring beans from module 3 and module 2 to module 1. 我需要将弹簧豆从模块3和模块2移至模块1。

Please help 请帮忙

in case you are using spring with xml configuration files you should import module 2 and module 3 application-context files in the module 1 application-context like below : 如果您将spring与xml配置文件一起使用,则应在模块1的应用程序上下文中导入模块2和模块3的应用程序上下文文件,如下所示:

<import resource="classpath*:file/location/module1application-context.xml" />
<import resource="classpath*:file/location/module2application-context.xml" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM