A little doubt about injection and generics

 qualifier will be directly injected into commonDao, not its subclass, not sub-Dao, (Dao in other places has no generic type, it will become CommonDao, plus the original, there will be two CommonDao,), this time When I injected CommonDao, I found that there were two, and an error was reported.
@Component
public class ActivitiDao extends CommonDao<Object> { //Generic type must be added, otherwise it will be considered as commondao, resulting in a few more commondao in commonservice
 
@Service
@Transactional
public class CommonService<T> {
	
	private static Logger logger = LoggerFactory.getLogger(CommonService.class);
	
	
	//@Qualifier(value="commonDao") //To cooperate with @Autowired, // Using @Qualifier will cause generics to disappear, not specific to the real subclass dao
	@Autowired
	private CommonDao<T> dao;
 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326863054&siteId=291194637