java - 如何将 Java 与带有嵌入式 Cassandra 的 Titan 连接起来

标签 java cassandra titan

我安装了titan-cassandra-0.4.4,我可以完美运行cassandra和gremlin(本地节点)。

我想用 Java 测试一个算法,所以我需要将 Java 连接到 titan。 我的 pom 是:

    <dependency>
        <groupId>com.thinkaurelius.titan</groupId>
        <artifactId>titan-core</artifactId>
        <version>0.4.4</version>
    </dependency>

我的代码是:

    BaseConfiguration baseConfiguration = new BaseConfiguration();
    baseConfiguration.setProperty("storage.backend", "cassandra");
    baseConfiguration.setProperty("storage.hostname", "127.0.0.1");
    baseConfiguration.setProperty("storage.tablename","test");

    TitanGraph titanGraph = TitanFactory.open(baseConfiguration);

在最后一行,错误是:

Exception in thread "main" java.lang.NoClassDefFoundError: com/netflix/astyanax/connectionpool/exceptions/ConnectionException
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.thinkaurelius.titan.diskstorage.Backend.getStorageManager(Backend.java:202)
at com.thinkaurelius.titan.diskstorage.Backend.<init>(Backend.java:97)
at com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration.getBackend(GraphDatabaseConfiguration.java:398)
at com.thinkaurelius.titan.graphdb.database.StandardTitanGraph.<init>(StandardTitanGraph.java:78)
at com.thinkaurelius.titan.core.TitanFactory.open(TitanFactory.java:60)
at Connecting.main(Connecting.java:20)
Caused by: java.lang.ClassNotFoundException: com.netflix.astyanax.connectionpool.exceptions.ConnectionException
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 8 more

我先启动cassandra,然后titan gremlin.sh,最后运行java代码。不知道是不是漏了什么?

提前致谢!

最佳答案

您应该包含对 titan-casssandra 的依赖。

    <dependency>
        <groupId>com.thinkaurelius.titan</groupId>
        <artifactId>titan-casssandra</artifactId>
        <version>0.4.4</version>
    </dependency>

另请注意,如果您刚刚开始使用 Titan,版本 0.4.4 已经过时了。 Titan 1.0 于 2015 年 9 月发布。您可以在 http://titandb.io 找到更多信息。

关于java - 如何将 Java 与带有嵌入式 Cassandra 的 Titan 连接起来,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33679535/

相关文章:

java - 在tomcat上部署项目后,日志中出现Scala错误

java - 类型安全警告如何避免泛型赋值

windows - 在Windows 7上启动cassandra错误系统找不到指定的路径

TITAN- 并行查询 - org.apache.tinkerpop.gremlin.driver.Client.submit 处的并发超时异常

java - Titan Factory.open() 配置

java - 如何从类内的另一个函数正确访问方法?

java - 如何跟踪 Web 应用程序中的请求。有没有什么工具可以用来测试 HTTP 请求

cassandra - 为什么我们在 Cassandra 中拍摄快照?

concurrency - Cassandra 中的柜台设计

hadoop - 基于 Apache Atlas 和 Hive,元数据存储在哪里?在 Titan Graph Repository 中还是在 RDBMS with Hive 中?