cannot construct a TypeToken for a type variable
阿新 • • 發佈:2018-11-04
遇到報錯“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;