0
votes

get this error when start spring boot application my spring boot application Spring Boot version 2.2.4 and cassandra version spring-data-cassandra 3.0.1.RELEASE

this is my error

Caused by: java.lang.ClassNotFoundException: org.springframework.data.convert.CustomConversions$ConverterConfiguration
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
    ... 113 common frames omitted

and my config class

 public class CassandraConfig {
    @Bean
    public CqlSessionFactoryBean session() {

        CqlSessionFactoryBean session = new CqlSessionFactoryBean();
        session.setContactPoints("localhost");
        session.setKeyspaceName("mykeyspace");
        session.setUsername("cassandra");
        session.setPassword("cassandra");
        session.setLocalDatacenter("dc1");
        return session;
    }

    @Bean
    public SessionFactoryFactoryBean sessionFactory(CqlSession session, CassandraConverter converter) {

        SessionFactoryFactoryBean sessionFactory = new SessionFactoryFactoryBean();
        sessionFactory.setSession(session);
        sessionFactory.setConverter(converter);
        sessionFactory.setSchemaAction(SchemaAction.NONE);

        return sessionFactory;
    }

    @Bean
    public CassandraMappingContext mappingContext(CqlSession cqlSession) {

        CassandraMappingContext mappingContext = new CassandraMappingContext();
        mappingContext.setUserTypeResolver(new SimpleUserTypeResolver(cqlSession));

        return mappingContext;
    }

    @Bean
    public CassandraConverter converter(CassandraMappingContext mappingContext) {
        return new MappingCassandraConverter(mappingContext);
    }

    @Bean
    public CassandraOperations cassandraTemplate(SessionFactory sessionFactory, CassandraConverter converter) {
        return new CassandraTemplate(sessionFactory, converter);
    }

}

how can in fix this error?

2

2 Answers

0
votes

Those versions are incompatible. spring-data-cassandra had a significant breaking changes from the 2.2.x version to 3.x.x version.

To use the 3.x.x version of Cassandra, you will to upgrade spring to 2.3.x. Either that or you will need to downgrade to 2.2.x version of spring-data-cassandra.

0
votes

i'm get a same exception,

when i upgrade the spring boot version, it's work!

 <dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.4.4</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>