0

我创建了一个 maven 项目,用于连接 cassandra 数据库并通过 cassandra astyanax java 客户端插入数据。

maven clean and install builds成功但是当我运行这个java应用程序时出现以下错误

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/cassandra/dht/Murmur3Partitioner
    at com.netflix.astyanax.impl.AstyanaxConfigurationImpl.<init>(AstyanaxConfigurationImpl.java:55)
    at ConnectingAstyanax.cassandraConnection(ConnectingAstyanax.java:23)
    at ConnectingAstyanax.main(ConnectingAstyanax.java:66)
Caused by: java.lang.ClassNotFoundException: org.apache.cassandra.dht.Murmur3Partitioner
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)

pom.xml如下

 <modelVersion>4.0.0</modelVersion>
  <groupId>CassandraAstyanax</groupId>
  <artifactId>CassandraAstyanax</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
          <source>1.7</source>
          <target>1.7</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <dependencies>
        <dependency>
              <groupId>com.netflix.astyanax</groupId>
              <artifactId>astyanax-thrift</artifactId>
              <version>1.56.31</version>
              </dependency>
              <dependency>
              <groupId>com.netflix.astyanax</groupId>
              <artifactId>astyanax-core</artifactId>
              <version>1.56.31</version>
              </dependency>
              <dependency>
              <groupId>com.netflix.astyanax</groupId>
              <artifactId>astyanax-cassandra</artifactId>
              <version>1.56.31</version>
              </dependency>
              <dependency>
                <groupId>org.apache.cassandra</groupId>
                <artifactId>cassandra-thrift</artifactId>
                <version>1.1.2</version>
            </dependency>
            <dependency>
                <groupId>org.apache.cassandra</groupId>
                <artifactId>cassandra-all</artifactId>
                <version>1.1.2</version>
            </dependency>


  </dependencies>
</project>

任何帮助解决错误将不胜感激..

4

1 回答 1

3

Murmur3Partitioner 是在 Cassandra 1.2 中引入的。您需要更新您的 pom 以引入 1.2 版本而不是 1.1。

于 2013-03-21T12:29:35.590 回答