I have a generics class DAO in my spring project,I have to get class of generic T.I know the pure java solution:
class Foo<T> {
final Class<T> typeParameterClass;
public Foo(Class<T> typeParameterClass) {
this.typeParameterClass = typeParameterClass;
}
public void bar() {
// you can access the typeParameterClass here and do whatever you like
}
}
But,in spring project,I have to get the Foo from the "ApplicationContext",I can't get Foo by:
Foo<ClassName> foo = new Foo<ClassName>(ClassName.class);
How to get class of generic type in Spring.