gpt4 book ai didi

java - Peapod : Impl is not abstract and does not override abstract method start() in peapod. FramedVertexTraversal

转载 作者:行者123 更新时间:2023-11-30 07:32:02 27 4
gpt4 key购买 nike

首先进行一些基本的修改来创建域模型。我让泰坦运行起来,添加了它的众神图并使用 gremlin 成功地遍历了它。

但是当我尝试创建 FramedGraph 时,我得到以下堆栈跟踪:

java.lang.ExceptionInInitializerError
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at java.lang.Class.newInstance(Class.java:442)
at peapod.internal.runtime.FramerRegistry.lambda$register$1(FramerRegistry.java:47)
at java.lang.Iterable.forEach(Iterable.java:75)
at peapod.internal.runtime.FramerRegistry.register(FramerRegistry.java:45)
at peapod.FramedGraph.<init>(FramedGraph.java:73)
at my.domain.model.Main.main(Main.java:28)
Caused by: java.lang.RuntimeException: Uncompilable source code - my.domain.model.vertices.Person$Impl is not abstract and does not override abstract method start() in peapod.FramedVertexTraversal
at my.domain.model.vertices.Person$Impl$PersonFramer.<clinit>(Person$Impl.java:14)
... 10 more

这是我的脚本:

public static void main(String[] args) {
System.out.println("--- Creating Titan client ---");
TitanGraph graph = TitanFactory.open("path/to/titan-1.0.0-hadoop1/conf/titan-cassandra-es.properties");
//GraphTraversalSource gremlin = graph.traversal();
System.out.println("--- Creating FramedGraph ---");
try {
FramedGraph g = new FramedGraph(graph, Package.getPackage("my.domain.model"));

//GraphOfTheGodsFactory.load(graph);
//Vertex saturn = gremlin.V().has("name", "saturn").next();
//System.out.println(saturn.value("name"));
System.out.println("--- Creating Person Vertex and adding it to the graph ---");
Person person = g.addVertex(Person.class);
System.out.println("--- Setting its name ---");
person.setName("alice");

System.out.println("--- Retriving all Persons with name ---");
List<Person> persons = g.V(Person.class).has("name", "alice").toList();

assert 1 == persons.size() : "More than one Person vertex found.";

g.close();
} catch (ExceptionInInitializerError e) {
e.printStackTrace();
} catch (Exception ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}

graph.close();
}

我的抽象 Person 类:

package my.domain.model.vertices;

import peapod.annotations.Vertex;

@Vertex
public abstract class Person{
public abstract String getName();
public abstract void setName(String name);
}

我使用的是Titan 1.0.0 Hadoop1,可能是版本问题,因为peapod使用Tinkerpop 3.0.0.M9-incubating而titan似乎使用 Tinkerpop 3.0.1-孵化中

最佳答案

来自豌 pod 的威廉。我测试了你的类(class)。

Peapod 需要 Java 8 并使用接口(interface)类中定义的默认方法。确保使用 Java 8 兼容性进行编译。

将其添加到您的 Maven pom.xml 文件

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>

关于java - Peapod : Impl is not abstract and does not override abstract method start() in peapod. FramedVertexTraversal,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35972962/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com