That is precisely what I am trying to do. The problem as far as I can tell is that the implementation class, JpaCrudDao, is getting the @Qualifier name attached to it, while I am injecting the Interface, CrudDao. In short:
Code:
@Repository
@Qualifier("crudDao")
public class JpaCrudDao implements CrudDao {
}
public class SomeClass {
final CrudDao crudDao;
@Autowired
public SomeClass(@Qualifier("crudDao") CrudDao c) {
this.crudDao = c;
}
}
complains upon container startup because many classes implement CrudDao. On a whim, I tried this:
Code:
@Repository("crudDao")
public class JpaCrudDao implements CrudDao {
}
public class SomeClass {
final CrudDao crudDao;
@Autowired
public SomeClass(@Qualifier("crudDao") CrudDao c) {
this.crudDao = c;
}
}
This works fine. Note, the only difference is that I pulled the @Qualifier from the JpaCrudDao, and named it using the @Repository annotation. I thought that @Qualifier was supposed to be used for this in the context of @Autowire.
Is this a bug?