弹簧组件可以用于多个包装

时间:2018-07-10 21:20:51

标签: spring

我希望Spring从2个不同的项目中进行依赖注入,并具有一个主要的@Configuration注释类,如下所示-

@Configuration
@EnableWebMvc
@ComponentScan(value = { "com.x.y", "com.a.b" })
public class AppConfig {
}     

com.x.y下的类是包含AppConfig类的软件包的一部分,而com.a.b下的类是包含在包含AppConfig类的war文件下的其他jar的一部分。

当我部署War文件时,出现错误-

Unsatisfied dependency expressed through constructor argument with index 0 of 
type [com.a.b.c.d.ClassA]: No qualifying bean of type [com.a.b.c.d.ClassA] 
found for dependency: expected at least 1 bean which qualifies as autowire 
candidate for this dependency. Dependency annotations: {}; nested exception 
is org.springframework.beans.factory.NoSuchBeanDefinitionException: 

我不确定使用@ComponentScan的方式有什么问题。寻找Spring专家的意见。

谢谢

0 个答案:

没有答案
相关问题