你的结构应该是这样的
SubscriberService接口
package com.spring.org.service;public interface SubscriberService {}SubscriberServiceImpl.java
package com.spring.org.service;@Component@Qualifier("Subscriber")public class SubscriberServiceImpl implements SubscriberService {}“ SubscriberServiceImpl1”是一个组件,它实现了“ SubscriberService”。
SubscriberServiceImpl1.java
package com.spring.org.service;@Component@Qualifier("Subscriber1")public class SubscriberServiceImpl1 implements SubscriberService {}我设置了一个Spring上下文,该上下文扫描这两个软件包中是否有标记为’@Component’的bean。
servlet-context.xml
<annotation-driven /><context:annotation-config /><context:component-scan base-package="com.spring"/>
HomeController.java
@Controllerpublic class HomeController { @Autowired @Qualifier("Subscriber") private SubscriberService subService;}从此 链接 参考。希望这能够帮到你....
编辑
根据您的包结构,您的 SubscriberServiceImpl 类位于 _com.spring.org.service_ 包
下, 只需使用 com.spring 更改您的基本包,这将对您 有用
<context:component-scan base-package="com.spring"/>



