我是 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