【问题标题】:GraphAware UUID generation not working while creating Neo4j nodes with Spring boot使用 Spring Boot 创建 Neo4j 节点时,GraphAware UUID 生成不起作用
【发布时间】:2018-03-15 21:29:29
【问题描述】:

我按照https://github.com/graphaware/neo4j-uuid 链接为从 Spring 引导应用程序创建的每个 neo4j 节点生成 UUID。 这是我按照链接执行的步骤列表:

  1. graphaware-uuid-3.3.3.52.16.jar 文件添加到Neo4jDB 的\plugins 文件夹。
    在我的情况下C:\Users\Naveen\AppData\Roaming\Neo4j Desktop\Application\neo4jDatabases\database-***\installation-3.3.2\plugins

  2. 在 \conf\neo4j.conf 文件中添加以下配置

    com.graphaware.runtime.enabled=true com.graphaware.module.UIDM.1=com.graphaware.module.uuid.UuidBootstrapper com.graphaware.module.UUID.uuidGeneratorClass=com.graphaware.module.uuid.generator.SequenceIdGenerator

  3. 在 Spring Boot 应用程序中创建 Model 类

    @NodeEntity 
    public class Skill {
        @GraphId
        private Long graphId;
    
        @Property(name = "uuid")
        private Long uuid;
    
        @Property(name = "skillName")
        private String skillName;
    
        //...getters and setters  
    }
    
  4. 创建 Spring Neo4j 数据仓库接口

    public interface SkillRepository extends GraphRepository<Skill> {  
    }
    
  5. 启动 Neo4j DB 并加载 Spring 上下文并测试配置:

    public Skill createkill() {
        Skill skill = new Skill();
        skill.setSkillName("Java");
        skill = skillRepository.save(skill);
        return skill;
    }
    

问题:在 Neo4j DB 中创建节点时会自动填充 graphId 属性,但未填充 uuid 属性。返回的 Skill 对象为 uuid 属性持有空值。

我检查了Graphaware Framework and UUID not starting on Neo4j GrapheneDBGraphAware UUID not generating 链接,但找不到任何解决我的问题的方法。

请帮忙看看我做错了什么,或者我是否遗漏了什么。 或者建议任何替代的uuid 生成解决方案。

使用的库和工具的版本详情:
Java 1.8.0_131
Neo4J 3.3.2 Enterprise
graphaware-uuid-3.3.3.52.16.jar
Spring boot 1.5.10

【问题讨论】:

    标签: neo4j uuid spring-data-neo4j graphaware


    【解决方案1】:

    正如@Bruno Peres 所述,所有配置和代码都是正确的,除了 我错过了在\plugins 文件夹中复制GraphAware ServerRuntime jars 及其依赖的jar。这是我放置在\plugins 文件夹中的 jar 列表,用于使用 GraphAware 成功启动 Neo4j DB 并生成 UUID。

    算法-3.0.4.43.5.jar
    changefeed-2.3.2.37.7.jar
    common-3.3.3.52.jar
    graphaware-uuid-3.3.3.52.16.jar
    kryo-2.24.0.jar
    minlog-1.2.jar
    nlp-3.3.2.52.6.jar
    objenesis-2.6.jar
    runtime-3.3.3.52.jar
    runtime-api-3.3.3.52.jar
    server-3.3.3.52.jar
    server-common-2.2.6.35.jar
    spring-beans-4.3.14.RELEASE.jar
    spring-context-4.3.14.RELEASE.jar
    spring-context-support-4.3.13.RELEASE.jar
    spring-core-4.3.14.RELEASE.jar
    spring-expression-4.3.14.RELEASE.jar
    timetree-3.3.3.52.27.jar
    tx-api-3.3.3.52.jar
    tx-executor-3.3.3.52.jar
    uuid-3.2.jar
    writer-3.3.3.52.jar
    writer-api-3.3.3.52.jar

    GraphAware 内部使用 spring 框架。这就是我在文件夹中包含弹簧罐的原因。

    【讨论】:

    • 您只能将图形感知和 neo4j-uuid jar 复制到插件目录中,它会起作用。
    【解决方案2】:

    UUID 属性不会在节点创建时返回,而只会在下一个事务中返回。

    您可以检查它使用您的 Java 应用程序创建一个节点并在 Neo4j 浏览器中通过该节点进行查询(或启动另一个事务并在 Java 应用程序中查询)。 UUID 属性应该存在。

    【讨论】:

    • 我在 Neo4j 浏览器和我的 java 应用程序中检查了不同的事务。但未生成 UUID 属性。幸运的是,您的回答引导我找到了根本原因。就我而言,我错过了在 \plugins 文件夹中添加 GraphAware ServerRuntime 罐子。添加所有依赖 jar 后,为所有节点生成一次 UUID。再次感谢。
    猜你喜欢
    • 2016-10-27
    • 2015-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-29
    • 1970-01-01
    • 2017-12-18
    • 1970-01-01
    相关资源
    最近更新 更多