Spring 4子模块注释



我使用Spring 4。X用于我最新的项目,没有xml,只有注释。它工作得很好,直到我决定将我的项目的一部分移动到一个子模块。我在项目jar的lib文件夹中看到子模块jar(使用spring引导jar maven插件来打包)。现在的问题是Spring不能识别子模块jar中的组件。两个jar的包名相同。

sample code
@EnableAutoConfiguration(exclude={JmsTemplateAutoConfiguration.class})
@ComponentScan("com.abc")
Structure
project.jar+
           |-lib+
                |-submodule.jar
Spring会为该包加载项目中的所有bean/组件,但不会从嵌入的jar文件中加载任何内容。加亮摘录:
No qualifying bean of type [com.abc.xxxx] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency....

我在这里做错了什么?

在多个jar文件中拆分包并不是一个好主意。我想如果您对包进行唯一命名就可以了。如果您认为可以在类加载器中修复,请在github中提出问题。

最新更新