My spring-boot/spring-data-cassandra application used to run well with Cassandra 2.1 but when I upgraded Cassandra to 3.3, it could not connect Cassandra server anymore. So in the pom file I decided to use a specific spring-data-cassandra module (1.3.2.RELEASE). I was hoping the new version of the spring-data-cassandra module will use the latest Cassandra Java driver. Though the new spring-data-cassandra module uses a newer version (2.1.5) of cassandra driver, it raised a weird exception when I ran the application:
[...CassandraConfig.class]; nested exception is java.lang.annotation.AnnotationFormatError: Invalid default: public abstract java.lang.Class org.springframework.data.cassandra.repository.config.EnableCassandraRepositories.repositoryBaseClass()
Does anyone out there know why this exception is raised? The code worked fine with Cassandra 2.1/spring-data-cassandra 1.1.3.
Does spring-data-cassandra support Cassandra 3.3.0?
The source code of the CassandraConfig class is listed below:
@Configuration
@PropertySource(value={"classpath:/device/repo/cassandra.properties"})
@EnableCassandraRepositories("device.repo")
public class CassandraConfig {
@Autowired
private Environment env;
@Bean
public CassandraClusterFactoryBean cluster() {
CassandraClusterFactoryBean cluster = new CassandraClusterFactoryBean();
cluster.setContactPoints(getContactPoints());
cluster.setPort(getPort());
return cluster;
}
@Bean
public CassandraMappingContext mappingContext() {
return new BasicCassandraMappingContext();
}
@Bean
public CassandraConverter converter() {
return new MappingCassandraConverter(mappingContext());
}
@Bean
public CassandraSessionFactoryBean session() throws Exception {
CassandraSessionFactoryBean session = new CassandraSessionFactoryBean();
session.setCluster(cluster().getObject());
session.setKeyspaceName(getKeyspaceName());
session.setConverter(converter());
session.setSchemaAction(SchemaAction.NONE);
return session;
}
@Bean
public CassandraOperations cassandraTemplate() throws Exception {
return new CassandraTemplate(session().getObject());
}
protected String getKeyspaceName() {
return env.getProperty("cassandra.keyspace");
}
protected String getContactPoints() {
return env.getProperty("cassandra.contactpoints");
}
protected int getPort() {
return Integer.parseInt(env.getProperty("cassandra.port"));
}
}
Thanks so much!