Rajkishan Rajkishan - 8 days ago 6
Java Question

Spring Boot with Cassandra 3.x driver

I use Spring boot

1.3.8.RELEASE
. To use cassandra 3.x driver i tried something like below;

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-cassandra</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-cassandra</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-cassandra</artifactId>
<version>1.4.0.RELEASE</version>
<exclusions>
<exclusion>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
</exclusion>
<exclusion>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-dse</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/com.datastax.cassandra/cassandra-driver-core -->
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
<version>3.1.0</version>
</dependency>


But i get error;

Caused by: java.lang.NoSuchMethodError: com.datastax.driver.core.DataType.asJavaClass()Ljava/lang/Class;
at org.springframework.data.cassandra.mapping.CassandraSimpleTypeHolder.<clinit>(CassandraSimpleTypeHolder.java:62) ~[spring-data-cassandra-1.4.0.RELEASE.jar:?]


I tried this cause at https://github.com/spring-projects/spring-boot/issues/5835 , there is a post ;


Adopting the Cassandra 3 changes in Spring Data Cassandra 1.5
(Ingalls) does not impose breaking changes for Spring Boot. Tested
the upgrade with Boot 1.3.3 and 1.4.0-SNAPSHOT.



Isn't it supposed to be like above?
Where i am wrong?

NOTE: I was trying this example: https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-data-cassandra

Answer

spring-data-cassandra-1.4.0.RELEASE depends on <cassandra.version>2.1.11</cassandra.version> and <cassandra-driver-dse.version>2.1.7.1</cassandra-driver-dse.version>see https://github.com/spring-projects/spring-data-cassandra/blob/1.4.0.RELEASE/pom.xml.

If you want to use Cassandra 3.x you should upgrade to spring-boot 1.5.x to benifit from spring-boot-starter-data-cassandra:1.5.x that depends on <cassandra.version>3.0.0</cassandra.version> and <cassandra-driver.version>3.0.3</cassandra-driver.version>see https://github.com/spring-projects/spring-data-cassandra/blob/1.5.0.M1/pom.xml

Remove Cassandra driver dependency from pom file. Spring boot will provide the right version

Comments