-
Notifications
You must be signed in to change notification settings - Fork 310
Closed as not planned
Closed as not planned
Copy link
Description
After Spring Boot 3 upgrade, AbstractCassandraConfiguration failed to create a cassandraTemplate with different bean name.
@Configuration
@EnableCassandraRepositories
public class TestCassandraConfig extends AbstractCassandraConfiguration {
@Override
protected String getKeyspaceName() {
return "keyspace";
}
@Override
protected String getContactPoints() {
return "localhost:9042";
}
@Override
protected String getLocalDataCenter() {
return "datacenter1";
}
@Override
@Bean("cassandraHealthCheckSession")
public CqlSessionFactoryBean cassandraSession() {
CqlSessionFactoryBean cassandraSession = super.cassandraSession();
cassandraSession.setUsername("username");
cassandraSession.setPassword("password");
return cassandraSession;
}
@Bean("cassandraHealthCheckTemplate")
@Override
public CassandraAdminTemplate cassandraTemplate() {
return new CassandraAdminTemplate(getRequiredSession(), requireBeanOfType(CassandraConverter.class));
}
@Bean
@Override
public SessionFactoryFactoryBean cassandraSessionFactory(CqlSession cassandraHealthCheckSession) {
return super.cassandraSessionFactory(cassandraHealthCheckSession);
}
@Override
protected CqlSession getRequiredSession() {
return getBeanFactory().getBean("cassandraHealthCheckSession", CqlSession.class);
}
@Override
protected SessionFactory getRequiredSessionFactory() {
return this::getRequiredSession;
}
}
Error:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cassandraTemplate' defined in class path resource [com/example/cassandratest/config/TestCassandraConfig.class]: No matching factory method found on class [com.example.cassandratest.config.TestCassandraConfig]: factory bean 'testCassandraConfig'; factory method 'cassandraTemplate()'. Check that a method with the specified name exists and that it is non-static.
I need multiple templates as I need to connect to multiple key spaces. Is there a way to make it work?
Metadata
Metadata
Assignees
Labels
No labels