import com.integrated.zyyt.ZyytConstant; import com.integrated.zyyt.enetity.StationInfo; import com.integrated.zyyt.enetity.business.Zyyt; import com.integrated.zyyt.enetity.business.ZyytStationInfo; import org.springframework.core.ResolvableType; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; /** * @ClassName FanXingTest * @Author cy * @Date 2022/11/16 * @Description * @Version 1.0 **/ public class FanXingTest { private List typelist1 = new ArrayList<>(); public static void main(String[] args) throws NoSuchFieldException { ResolvableType t = ResolvableType.forField(FanXingTest.class.getDeclaredField("typelist1")); System.out.println(t.getGeneric(0).resolve()); Zyyt infoZyyt = new ZyytStationInfo(ZyytConstant.URL_AUTHON,ZyytConstant.URL_DJTJB_QUERY, false, ZyytConstant.CLIENT_DJTJB, ZyytConstant.SECRET_DJTJB, ZyytConstant.X_EOS_SOURCESYSKEY_DJTJB, null); Type genType = infoZyyt.getClass().getGenericSuperclass(); Type[] params = ((ParameterizedType) genType).getActualTypeArguments(); System.out.println(((Class) params[0]).getName()); ResolvableType t2 = ResolvableType.forField(infoZyyt.getClass().getDeclaredField("queryData")); System.out.println(t2.getGeneric(0).resolve()); } }