【发布时间】:2018-06-15 04:55:15
【问题描述】:
我正在使用 SpringBoot 1.5.4.RELEASE、ArangoDB java 驱动程序 4.5.0、Arango Spring Data 1.1.5
检索对象时出现此错误。
com.arangodb.velocypack.exception.VPackParserException: java.lang.InstantiationException: com.arangodb.springframework.core.convert.DBEntity
我还找不到根本原因(仍在寻找),但我可以看到错误在哪里抛出,在 VPack 类中有这个方法
private <T> T createInstance(final Type type) throws InstantiationException, IllegalAccessException {
final T entity;
final VPackInstanceCreator<?> creator = instanceCreators.get(type);
if (creator != null) {
entity = (T) creator.createInstance();
} else if (type instanceof ParameterizedType) {
entity = createInstance(((ParameterizedType) type).getRawType());
} else {
entity = ((Class<T>) type).newInstance();
}
return entity;
}
但传入的类型是接口com.arangodb.springframework.core.convert.DBEntity。这个没有创建者,也不是参数化类型,所以调用了newInstance。这当然失败了。
这似乎源于 find 方法中的ArangoTemplate。这里是传入 DBEntity.class 的地方。
@Override
public <T> Optional<T> find(final String id, final Class<T> entityClass, final DocumentReadOptions options)
throws DataAccessException {
try {
final DBEntity doc = _collection(entityClass, id).getDocument(determineDocumentKeyFromId(id),
DBEntity.class, options);
return Optional.ofNullable(fromDBEntity(entityClass, doc));
} catch (final ArangoDBException e) {
throw translateExceptionIfPossible(e);
}
}
我正在尝试创建一个可以按需生成的测试。如果我成功了,我会在这里发帖。
谢谢,
西蒙
【问题讨论】:
标签: java spring-data deserialization arangodb