简体   繁体   English

在Java中创建Neo4j关系时出错

[英]Error creating Neo4j relationships in java

I have created nodes and relationships in java, their values are coming from DB and will be dynamically assigned. 我已经在Java中创建了节点和关系,它们的值来自DB,并将动态分配。

GraphDatabaseService graphDb= new GraphDatabaseFactory().newEmbeddedDatabase("D://MyGraph);
//Data access logic Code here
.............
while(rs.next())
{
    String node1=   rs.getString("App_Name"); 
    String rel  =   rs.getString("Interface_Name");
    String node2=   rs.getString("Corresponding_App");
    Transaction tx=graphDb.beginTx();       
    try{        
        RelationshipType rel1 =DynamicRelationshipType.withName(rel);                       
        Node nodeName1 = graphDb.createNode(); 
        Node nodeName2 = graphDb.createNode();                  
        nodeName1.addLabel(DynamicLabel.label((node1)));                    
        nodeName1.setProperty("name", (node1));
        nodeName2.addLabel(DynamicLabel.label((node2)));                    
        nodeName2.setProperty("name", (node2));
        nodeName1.createRelationshipTo(nodeName2, rel1);
        tx.success();
        ...
    }
    ...
}

However i am getting an error -- 但是我遇到一个错误-

"java.lang.AbstractMethodError: org.neo4j.graphdb.index.IndexProvider.load(Lorg/neo4j/graphdb/DependencyResolver;)Lorg/neo4j/graphdb/index/IndexImplementation;  at org.neo4j.graphdb.index.IndexProviderKernelExtensionFactory$IndexProviderKernelExtension.start(IndexProviderKernelExtensionFactory.java:72)
       at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:498)"

Please guide. 请指导。

As Stefan already suggested, you're having version conflicts with your jars. 正如Stefan已经建议的那样,您的jar版本冲突。 I strongly advise you to use maven or gradle to manage your dependencies. 我强烈建议您使用Maven或Gradle来管理依赖项。 Neo4j 2.0.1 has the following dependencies, in case you still want to add them manually to your project: Neo4j 2.0.1具有以下依赖关系,以防您仍然希望将其手动添加到项目中:

[INFO] \- org.neo4j:neo4j:jar:2.0.1:compile
[INFO]    +- org.neo4j:neo4j-kernel:jar:2.0.1:compile
[INFO]    |  \- org.apache.geronimo.specs:geronimo-jta_1.1_spec:jar:1.1.1:compile
[INFO]    +- org.neo4j:neo4j-lucene-index:jar:2.0.1:compile
[INFO]    |  \- org.apache.lucene:lucene-core:jar:3.6.2:compile
[INFO]    +- org.neo4j:neo4j-graph-algo:jar:2.0.1:compile
[INFO]    +- org.neo4j:neo4j-udc:jar:2.0.1:compile
[INFO]    +- org.neo4j:neo4j-graph-matching:jar:2.0.1:compile
[INFO]    +- org.neo4j:neo4j-cypher:jar:2.0.1:compile
[INFO]    |  +- org.neo4j:neo4j-cypher-commons:jar:2.0.1:compile
[INFO]    |  +- org.neo4j:neo4j-cypher-compiler-1.9:jar:2.0.1:compile
[INFO]    |  +- org.neo4j:neo4j-cypher-compiler-2.0:jar:2.0.1:compile
[INFO]    |  |  \- org.parboiled:parboiled-scala_2.10:jar:1.1.6:compile
[INFO]    |  |     \- org.parboiled:parboiled-core:jar:1.1.6:compile
[INFO]    |  +- com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:jar:1.3.1:compile
[INFO]    |  \- org.scala-lang:scala-library:jar:2.10.3:compile
[INFO]    \- org.neo4j:neo4j-jmx:jar:2.0.1:compile

This looks most likely like having mixed versions of Neo4j on your classpath. 这看起来很像在您的类路径中混合了Neo4j的版本。 Make sure that all Neo4j jars are used with the same version, that there are no duplicate jars on the classpath and all the dependencies are in place. 确保所有Neo4j jar都使用相同的版本,并且在类路径上没有重复的jar,并且所有依赖项都已就位。

If further help is required, attach the current classpath settings here. 如果需要进一步的帮助,请在此处附加当前的类路径设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM