我在 2.0.12 中使用下面的 API 获取顶点并且它正在工作
OrientGraphFactory factory = new OrientGraphFactory("remote:172.21.112.228/mydb", "root", "root").setupPool(1,50);
OrientGraphNoTx graph = factory.getNoTx();
graph.getVertices("Test.name","zyx");
但是使用最新的 2.2.18,当我尝试使用
OrientGraphFactory factory = new OrientGraphFactory("memory:172.21.112.228/mydb", "root", "root").setupPool(1,50);
OrientGraphNoTx graph = factory.getNoTx();
graph.getVertices("Test.name","zyx");
我低于错误,
Exception in thread "main" java.lang.IllegalArgumentException:
OClass not found in the schema: Test
at com.tinkerpop.blueprints.impls.orient.OrientBaseGraph.getVertices(OrientBaseGraph.java:814)
at test.GetOrientDBData.main(GetOrientDBData.java:57)
尝试以下代码:
OrientGraphFactory factory = new OrientGraphFactory("memory:mydb",
"root", "root").setupPool(1,50);
OrientGraphNoTx graph = factory.getNoTx();
if(g.getVertexType("Test") == null){
g.createVertexType("Test");
}
graph.getVertices("Test.name","zyx");
您的代码有两处更改:
去掉内存中的IP: URL,不用那个
添加了一个检查以确保测试类存在并创建它