从Spring(v4.3.8)开始,当Spring尝试加载依赖项注入时遇到一个问题。我想基于T(Debit1或Debit2)的类型调用ManagerImpl1.java或ManagerImpl2.java实现的“管理”方法。详细信息如下:由以下原因引起:org.springframework.beans.factory.NoUniqueBeanDefinitionException:没有类型为'com.xxx.xxx.datacollection.infoprod.Manager'的合格Bean:预期为单个匹配的Bean,但找到了2:ManagerImpl1,ManagerImpl2Business.java:@Componentpublic class Business<T extends Debit> { @Autowired private Manager<T> manager; public void treatment(Context<T> context, FindServiceReturnMessage response) { manager.manage(response, context); }Manager.java:public interface Manager<T extends Debit> { void manage(final FindServiceReturnMessage response, Context<T> context);}ManagerImpl1.java:@Componentpublic class ManagerImpl1 implements Manager<Debit1> { @Override public void manage(final FindServiceReturnMessage response, Context<Debit1> context) { }}ManagerImpl2.java:@Componentpublic class ManagerImpl2 implements Manager<Debit2> { @Override public void manage(final FindServiceReturnMessage response, Context<Debit2> context) { }}同样,“借方1”和“借方2”实现接口“借方”。我尝试了几件事但没有成功...
添加回答
举报
0/150
提交
取消