刚入门的小白求教使用Java api的问题
发布于 6 年前 作者 haozz94 2266 次浏览 来自 问答

这是我的Java代码 package ark.test; import java.io.File; import org.neo4j.graphdb.GraphDatabaseService; import org.neo4j.graphdb.Label; 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 test1 {

public enum Teacher implements Label{
	Chinese,Math,English;
}

public enum Relationships implements RelationshipType{
	colleagues,no_colleagues;
}

public static void main(String[] args) {
	
	GraphDatabaseFactory dbfactory = new GraphDatabaseFactory();
	
	GraphDatabaseService db = dbfactory.newEmbeddedDatabase(new File("D:/test1"));
	
	try (Transaction tx = db.beginTx()) {
		
		Node CNnode = db.createNode(Teacher.Chinese);
		CNnode.setProperty("name", "李玲");
		CNnode.setProperty("age", 44);
		CNnode.setProperty("book", "大学语文");
		CNnode.setProperty("pages", 100);
		
		Node MathNode = db.createNode(Teacher.Math);
		MathNode.setProperty("name", "赵四");
		MathNode.setProperty("age", 47);
		MathNode.setProperty("book", "高等数学");
		MathNode.setProperty("pages", 200);
		
		Relationship rea = CNnode.createRelationshipTo(MathNode, Relationships.colleagues);
		rea.setProperty("ID", "111");
		
		tx.success();
		
	}catch (Exception e) {
	
	}finally {
		db.shutdown();
	}
	System.out.println("Done successfully");
}

}

在D盘test1创建了新的库,然后使用窗口连接test1点击start后提示下面这行代码 Failed to start Neo4j with an older data store version. To enable automatic upgrade, please set configuration parameter "dbms.allow_format_migration=true" 然后在配置里打开了他让打开的 还是没成功 有提示这些 Starting Neo4j failed: Component ‘org.neo4j.server.database.LifecycleManagingDatabase@2b7d38ac’ was successfully initialized, but failed to start. Please see attached cause exception. 对于一个小白来说 简直难倒自己了 有人遇到过这个问题或者知道如何解决吗 谢谢

2 回复

是因为我使用的Neo4j的jar包版本和exe版本不一致的原因吗

已解决 之前使用的是3.3.5的jar包,exe端是3.1.0 将jar包改为同样的3.1.0之后问题解决了

回到顶部