cannot construct a TypeToken for a type variable

遇到报错“cannot construct a TypeToken for a type variable”,如下信息

Caused by: java.lang.IllegalStateException: Cannot construct a TypeToken for a type variable.
You probably meant to call new TypeToken<T>(getClass()) that can resolve the type variable for you.
If you do need to create a TypeToken of a type variable, please use TypeToken.of() instead.
	at com.google.common.base.Preconditions.checkState(Preconditions.java:588)
	at com.google.common.reflect.TypeToken.<init>(TypeToken.java:126)
	at com.huawei.scp.testmgmt.model.VersionTypeToken.<init>(VersionTypeToken.java:7)
	at com.huawei.scp.testmgmt.service.impl.TestCaseServiceImpl.<clinit>(TestCaseServiceImpl.java:83)
	... 48 common frames omitted

确定你自己的TypeToken导入的包是否正确..

是上面这个 import com.google.gson.reflect.TypeToken;

而不是下面这个 import com.google.common.reflect.TypeToken;

猜你喜欢

转载自blog.csdn.net/VeastLee/article/details/82691727