簡體   English   中英

如何使用嵌入式Cassandra將Java與Titan連接起來

[英]How to connect Java with Titan with embedded Cassandra

我安裝了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包含一個依賴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上找到更多信息

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM