1

我是 Neo4J 的新手,并遵循 neo4j 网站 ( http://docs.neo4j.org/chunked/milestone/tutorials-java-embedded-hello-world.html ) 上的 HelloWorld 教程。

我的目的是创建 2 个节点和它们之间的关系,最后在可通过以下方式访问的仪表板上观察这一点

[http://localhost:7474/webadmin/#] 

但问题是当我运行我的代码时出现错误,我不知道如何解决它。

任何帮助将非常感激

非常感谢你

这是我的代码和错误

代码

import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.RelationshipType;
import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;

public class HelloNeo4J {

private static enum RelTypes implements RelationshipType
{
    KNOWS
}

public static String DB_PATH= " /home/anas/graph/data/graph.db/" ; 

public static void main ( String[] args){

    GraphDatabaseService graphDb= new GraphDatabaseFactory().newEmbeddedDatabase( DB_PATH );
    Node firstNode, secondNode;
    Relationship relationship;

    Transaction tx = graphDb.beginTx();
    try
    {
        firstNode = graphDb.createNode();
        firstNode.setProperty( "message", "Hello, " );
        secondNode = graphDb.createNode();
        secondNode.setProperty( "message", "World!" );

        relationship = firstNode.createRelationshipTo( secondNode, RelTypes.KNOWS );
        relationship.setProperty( "message", "brave Neo4j " );
        tx.success();
    }
    finally
    {
        tx.finish();
    }

}
}

错误

Exception in thread "main" org.neo4j.kernel.lifecycle.LifecycleException: Failed to transition org.neo4j.kernel.AbstractGraphDatabase$DefaultKernelExtensionLoader@691f36 from NONE to STOPPED
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.init(LifeSupport.java:388)
at org.neo4j.kernel.lifecycle.LifeSupport.init(LifeSupport.java:82)
at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:116)
at org.neo4j.kernel.AbstractGraphDatabase.run(AbstractGraphDatabase.java:224)
at org.neo4j.kernel.EmbeddedGraphDatabase.<init>(EmbeddedGraphDatabase.java:79)
at org.neo4j.graphdb.factory.GraphDatabaseFactory$1.newDatabase(GraphDatabaseFactory.java:70)
at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:195)
at org.neo4j.graphdb.factory.GraphDatabaseFactory.newEmbeddedDatabase(GraphDatabaseFactory.java:56)
at HelloNeo4J.main(HelloNeo4J.java:20)
Caused by: java.lang.VerifyError: class org.neo4j.kernel.InternalAbstractGraphDatabase overrides final method getStoreDir.()Ljava/lang/String;
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
at org.neo4j.index.lucene.LuceneIndexProvider.load(LuceneIndexProvider.java:65)
at org.neo4j.kernel.AbstractGraphDatabase$DefaultKernelExtensionLoader.loadIndexImplementations(AbstractGraphDatabase.java:1180)
at org.neo4j.kernel.AbstractGraphDatabase$DefaultKernelExtensionLoader.init(AbstractGraphDatabase.java:1152)
at  org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.init(LifeSupport.java:382)
    ... 8 more
4

2 回答 2

3

有两个问题,

首先:信息:在日志中检测到非干净关闭...恢复已开始

您看到的信息是因为您没有使用 db.shutdown() 彻底关闭数据库,因此它必须恢复未应用的事务日志。

第二:

如果您想在 Neo4j-Server 中查看结果,您必须使用与中相同的 db-directory,conf/neo4j-server.properties并且您必须在向其写入数据时停止服务器。

Oherwise 您也可以在嵌入式数据库之上运行服务器,请参阅:http ://docs.neo4j.org/chunked/milestone/server-embedded.html

于 2013-03-27T20:22:25.363 回答
0

请实现一个图形数据库(一种 NoSQL)。该图数据库应由实体的节点(具有属性)和关系的边(具有单个或多个属性,可以是定向的或双向的)组成,并支持节点索引和查询。查询语言具有以下关键字:START、MATCH、WHERE、RETURN、ORDER BY、AGGREGATE、SKIP 和 LIMIT。

于 2014-02-15T03:47:45.590 回答