[春季3.0.5]
[jboss 5.1]
我有几个标记为@Service的类,它实现了相同的接口.
例如,
@Service(value="test1")
public TestImpl1 implements Test {}
@Service(value="test2")
public TestImpl2 implements Test {}
接下来,我有以下结构
public SomeClass {
@Autowired
@Qualifier("test1")
Test test1;
@Autowired
@Qualifier("test2")
Test test2;
我得到一个例外(在部署时)
10:36:58,277 ERROR [[/test-web]] Servlet /test-web threw load()
exception
org.springframework.beans.factory.NoSuchBeanDefinitionException: No
unique bean of type [pl.tests] is defined: expected single matching
bean but found 2: [test1,test2]
at
org.springframework.beans.factory.support.DefaultListablebeanfactory.doReso lveDependency(DefaultListablebeanfactory.java:
796)
at
org.springframework.beans.factory.support.DefaultListablebeanfactory.resolv eDependency(DefaultListablebeanfactory.java:
703)
at
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostPro cessor
$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:
474)
有谁知道如何解决这个问题?
T.
最佳答案