It is obviously right to inject one generic bean through @Autowired annotation since spring 4.0 just like this:
@Autowired
private GenericClass<Person> genericPerson;
But I can not find a proper way to fetch it through BeanFactory or ApplicationContext just like:
ApplicationContext.getBean(GenericClass<Person>.class)
I do know there is some wrong in syntax, but there must be some other way to realize it, right?
Comment From: dayAndnight2018
I know that it will fetch all subClasses that extends GenericClass through
ApplicationContext.getBeansOfType(GenericClass.class)
But that is not what I want...
Comment From: snicoll
beanFactory.getBeanProvider(ResolvableType)
with ResolvableType.forClassWithGenerics(GenericClass, Person.class)
should do the trick.
If you have further questions, please ask on StackOverflow.