demo
public abstract class AvconBaseServiceImpl<M extends BaseMapper<T>, T extends BaseEntity> extends ServiceImpl<M, T> { @Autowired protected M baseDao; @Autowired EmsEsDeviceDao emsEsDeviceDao; protected Log log = LogFactory.getLog(getClass()); protected T initEntity(EmsEsBizDTO emsEsBizDTO) throws Exception { // 本类的泛型参数 ParameterizedType ptype = (ParameterizedType) this.getClass().getGenericSuperclass(); // 下标1表示第二个参数: T的Class Class<T> clazz = (Class<T>) ptype.getActualTypeArguments()[1]; return this.initEntity(emsEsBizDTO, clazz); }
}
标签:getClass,ptype,protected,参数,泛型,Class From: https://www.cnblogs.com/eason-d/p/18109068