ResolvableType Spring 的java類型通用解析器java
獲取當前類型泛型spa
public class A<T>{ protected String namespace; public A(){ ResolvableType t=ResolvableType.forType(getClass().getGenericSuperclass()); namespace=t.getGeneric(0).resolve().getSimpleName(); } } public class Test extends A<String>{ public void printName(){ System.out.println(namespace); } public static void main(String[] args) { new Test().printName(); } }