I have the following code structure
@Component
public class MyServiceUser{
@Autowired
private MyService<FirstMyDao> dao;
}
@Service
public class MyService<T extends AbstractMyDao>{
@Autowired
private T myDao;
}
abstract class AbstractMyDao{}
@Repository
class FirstMyDao extends AbstractMyDao{}
@Repository
class SecondMyDao extends AbstractMyDao{}
Spring said that he can't resolve which type of dao set in service. Can I do it? I read a few articles but didn't find the answer(https://blog.jayway.com/2013/11/03/spring-and-autowiring-of-generic-types/ , How to Autowire Bean of generic type <T> in Spring?).