NodeBacked实体NPE-实体状态为null [英] NodeBacked entity NPE - entityState is null

查看:102
本文介绍了NodeBacked实体NPE-实体状态为null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个示例项目,该项目使用Spring Data Neo4j通过Aspectj进行的高级映射.在NullPointerException的测试中失败,这是因为在持久化实体时,entityState属性为null.

I've got a sample project which uses Spring Data Neo4j's advanced mapping using aspectj. It's failing in a test with NullPointerException due to the entityState attribute being null at the time when the entity is being persisted.

当服务器本身启动并执行时,我也可以复制此代码:

I can also replicate this when the server itself is spun up and I execute:

curl -i -X POST -H "Content-Type:application/json" -d '{  "firstName" : "Test",  "lastName" : "Person" }' http://localhost:8080/people

该项目位于 https://github.com/dhallam/spring-data- neo4j-demo ,带有日志的Travis构建位于 https://travis-ci.org/dhallam/spring-data-neo4j-demo/builds/22538972 .

The project is at https://github.com/dhallam/spring-data-neo4j-demo and the Travis build with the logs is at https://travis-ci.org/dhallam/spring-data-neo4j-demo/builds/22538972.

我不确定我是否缺少某些东西,或者是否存在需要我提出JIRA问题的错误.

I'm not sure whether I'm missing something or there is a bug that would require me to raise a JIRA issue.

有什么想法吗?预先非常感谢.

Any ideas? Many thanks in advance.

版本:Java v1.7; SDNeo4j v3.1.0.M1; SDRest v2.1.0.M1; Neo4j v2.0.1;码头v9.0.5.v20130815; AspectJ v1.7.4

Versions: Java v1.7; SDNeo4j v3.1.0.M1; SDRest v2.1.0.M1; Neo4j v2.0.1; Jetty v9.0.5.v20130815; AspectJ v1.7.4

尝试从下面迈克尔的评论中将@JsonIgnoreProperties添加到Person(@NodeEntity),但仍然失败.失败的代码是当我运行时:

Tried adding @JsonIgnoreProperties to the Person (@NodeEntity)from Michael's comment below and it's still failing. The bit of code that is failing is when I run:

Person p = new Person();
// setters ...
p.persist();

persist()调用

public <T extends NodeBacked> T NodeBacked.persist() {
    return (T)this.entityState.persist();
}

entityState为空.

推荐答案

弄清楚了. Neo4jConfig类以前扩展了Neo4jConfiguration类.随着方面的引入,需要将该超类更新为Neo4jAspectConfiguration,以提供其他的neo4jRelationshipBackingneo4jNodeBacking bean.

Figured it out. The Neo4jConfig class previously extended the Neo4jConfiguration class. With the introduction of aspects, that superclass needed to be updated to be Neo4jAspectConfiguration to provide the additional neo4jRelationshipBacking and neo4jNodeBacking beans.

我已经在 https://github.com/dhallam上更新了github参考项目./spring-data-neo4j-demo ,构建就通过了.

I've updated the github reference project at https://github.com/dhallam/spring-data-neo4j-demo and the build is passing.

这篇关于NodeBacked实体NPE-实体状态为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆