我遵循了来自 SDN3 的 SDN4 迁移路径,并遇到了此处记录的相同问题:SDN4 - Neo4j OGM - Jackson 2
答案中引用了一个补丁,并提到它将应用于 neo4j-ogm 1.1.1。从那以后,我尝试了 1.1.1 和 1.1.2 版本,但没有成功。这是我的带有 JsonSubType 注释的 SDN 注释实体的示例。我正在使用杰克逊注释 2.6.2。
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.WRAPPER_OBJECT)
@JsonSubTypes({
@JsonSubTypes.Type(value = au.com.guml.domain.uml.Package.class, name = "Package"),
@JsonSubTypes.Type(value = au.com.guml.domain.uml.Class.class, name = "Class"),
@JsonSubTypes.Type(value = au.com.guml.domain.uml.diagram.Diagram.class, name = "Diagram")
})
@NodeEntity
public interface PackageableElement extends NamedElement {
public Integer getSequence();
public void setSequence(Integer sequence);
}
如果我注释掉 JsonSubTypes 注释,我的单元测试就可以工作。但是,将其放入链接的stackoverflow问题会导致异常。
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.neo4j.ogm.session.SessionFactory]: Factory method 'getSessionFactory' threw exception; nested exception is java.lang.ClassFormatError: Invalid annotation element type tag: 0x0
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:591)
... 45 more
Caused by: java.lang.ClassFormatError: Invalid annotation element type tag: 0x0
任何想法,解决方法?在我看来,该补丁尚未应用于 neo4j-ogm 的发行版。