I am new to using Spring Boot Applications. I would like to know how to connect cassandra database to the application. I added this dependency in the pom.xml file :
<dependency>
<groupId>com.datastax.oss</groupId>
<artifactId>java-driver-core</artifactId>
<version>4.1.0</version>
</dependency>
And these lines to the application.yml file :
spring:
data:
cassandra:
keyspace-name: test-keyspace
contact-points: localhost
port: 9042
schemaAction: CREATE_IF_NOT_EXISTS
request:
timeout: 10s
connection:
connect-timeout: 10s
locaDatacenter: datacenter1
However, when I run the application, I get such errors :
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name'org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration':
Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'cassandraSession' defined in class path resource [org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.class]:
Unsatisfied dependency expressed through method 'cassandraSession' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'cassandraSessionBuilder' defined in class path resource [org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.class]:
Unsatisfied dependency expressed through method 'cassandraSessionBuilder' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'cassandraDriverConfigLoader' defined in class path resource [org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.class]:
Bean instantiation via factory method failed;
nested exception is org.springframework.beans.BeanInstantiationException:
Failed to instantiate [com.datastax.oss.driver.api.core.config.DriverConfigLoader]: Factory method 'cassandraDriverConfigLoader' threw exception; nested exception is java.lang.NoSuchFieldError: CONNECTION_CONNECT_TIMEOUT