我有三个课程。基类,从基类扩展的子类和从第一个子类扩展的子类,如:
@Service
public abstract class BaseClass<T> {
private Type type = ((ParameterizedType)this.getClass().getGenericSuperclass()).getActualTypeArguments()[0]
}
@Service
public class SubClass extends BaseClass<MyType> {
private static final String URL = "/test"
public MyType mainMethodOfThisClass(...) {
...
}
protected String getUrl() {
return URL;
}
}
@Service
public class SubSubClass extends SubClass{
private static final String URL = "/test/test"
@Override
protected String getUrl() {
return URL;
}
}
现在我
“创建名为'SubSubClass'的bean时出错'引起: org.springframework.beans.BeanInstantiationException:失败 instantiate由以下引起:java.lang.ClassCastException:java.lang.Class 无法转换为java.lang.reflect.ParameterizedType
我在SubClass中定义Type。为什么我必须在SubSubClass中再次定义Type?