I am trying few proof of concepts to test it for time series data. I took the sample from spring website and configured it on eclipse.

Below are few details:

Cassandra Version** - 3.0.9 Spring data cassandra version - 1.0.0.RELEASE DataStax java driver core- cassandra-driver-core-3.1.2

I am executing the below code:

Cluster cluster = Cluster.builder().addContactPoints("127.0.0.1").withPort(9042).build();
          Session session = cluster.connect("axiaglobal");
       CassandraOperations cassandraOps = new CassandraTemplate(session);

       cassandraOps.insert(new Person("1234567890", "David", 40));

and Person.java is below:

@Table
public class Person {
 @PrimaryKey
 private String id;

 private String name;
 private int age;

 public Person(String id, String name, int age) {
  this.id = id;
  this.name = name;
  this.age = age;
 }

 public String getId() {
  return id;
 }

 public String getName() {
  return name;
 }

 public int getAge() {
  return age;
 }

 @Override
 public String toString() {
  return "Person [id=" + id + ", name=" + name + ", age=" + age + "]";
 }

}

While exeucting the code, i get the below exception:

Exception in thread "main" java.lang.NoSuchMethodError: com.datastax.driver.core.DataType.asJavaClass()Ljava/lang/Class;
    at org.springframework.data.cassandra.mapping.CassandraSimpleTypeHolder.<clinit>(CassandraSimpleTypeHolder.java:62)
    at org.springframework.data.cassandra.mapping.BasicCassandraMappingContext.<init>(BasicCassandraMappingContext.java:73)
    at org.springframework.data.cassandra.convert.MappingCassandraConverter.<init>(MappingCassandraConverter.java:77)
    at org.springframework.data.cassandra.core.CassandraTemplate.<init>(CassandraTemplate.java:75)
    at com.axia.global.dao.cassandra.service.CassandraApp.main(CassandraApp.java:26)

Can someone please help me out with the suggestions or pointers?

1

There are 1 answers

0
lxwde On

change pom file as below solved my issue:

<dependency>
        <groupId>org.cassandraunit</groupId>
        <artifactId>cassandra-unit-spring</artifactId>
        <version>3.1.1.0</version>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>org.cassandraunit</groupId>
                <artifactId>cassandra-unit</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.cassandraunit</groupId>
        <artifactId>cassandra-unit</artifactId>
        <classifier>shaded</classifier>
        <version>3.1.1.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.datastax.cassandra</groupId>
        <artifactId>cassandra-driver-core</artifactId>
        <version>3.1.1</version>
        <optional>true</optional>
        <!--<exclusions>-->
        <!--<exclusion>-->
        <!--<groupId>com.google.guava</groupId>-->
        <!--<artifactId>guava</artifactId>-->
        <!--</exclusion>-->
        <!--</exclusions>-->
    </dependency>