DB_PATH出错,求解答
发布于 8 年前 作者 onepint 4347 次浏览 来自 问答

报错:The method newEmbeddedDatabase(File) in the type GraphDatabaseFactory is not applicable for the arguments (String) 请问怎么改? 源码: package com.tp.neo4j.java.examples;

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

public class Neo4jJavaAPIDBOperation { public static void main(String[] args) { GraphDatabaseFactory dbFactory = new GraphDatabaseFactory(); GraphDatabaseService db= dbFactory.newEmbeddedDatabase(“C:/TPNeo4jDB”); try (Transaction tx = db.beginTx()) {

	Node javaNode = db.createNode(Tutorials.JAVA);
	javaNode.setProperty("TutorialID", "JAVA001");
	javaNode.setProperty("Title", "Learn Java");
	javaNode.setProperty("NoOfChapters", "25");
	javaNode.setProperty("Status", "Completed");				
	
	Node scalaNode = db.createNode(Tutorials.SCALA);
	scalaNode.setProperty("TutorialID", "SCALA001");
	scalaNode.setProperty("Title", "Learn Scala");
	scalaNode.setProperty("NoOfChapters", "20");
	scalaNode.setProperty("Status", "Completed");
	
	Relationship relationship = javaNode.createRelationshipTo
	(scalaNode,TutorialRelationships.JVM_LANGIAGES);
	relationship.setProperty("Id","1234");
	relationship.setProperty("OOPS","YES");
	relationship.setProperty("FP","YES");
	
	tx.success();
}
   System.out.println("Done successfully");

} }

1 回复

API更新后newEmbeddedDatabase(File)的参数是File不是String。所以你传File(“path”)就行了

回到顶部