Spring JavaConfig - NoSuchBeanDefinitionException: No unique bean of type

来源:互联网 发布:梦幻西游数据号 编辑:程序博客网 时间:2024/06/03 06:00

原报错代码:Service中定义

@Autowired

private TestDao testDao;

TestDao定义如下


@Repository
public interface TestDao {

public void say();

}

  

TestDao实现定义:

@Repository
public class TestDaoImpl2 implements TestDao {


@Override
public void say() {
System.out.println("2222222222222222222222222222222222222222222222");
}


}

@Repository
public class TestDaoImpl3 implements TestDao {


@Override
public void say() {
System.out.println("333333333333333333333333333333333333333333333333333333333333");
}


}




改后的Service
@Autowired
@Qualifier("testDaoImpl2")
private TestDao testDao2;

@Autowired
@Qualifier("testDaoImpl3")
private TestDao testDao3;
原创粉丝点击