Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CassandraDataAutoConfiguration.cassandraTemplate(…) declares Operations interface instead of implementation class [DATACASS-600] #718

Closed
spring-projects-issues opened this issue Oct 12, 2018 · 4 comments
Assignees
Labels
in: core type: bug

Comments

@spring-projects-issues
Copy link

spring-projects-issues commented Oct 12, 2018

Alexandru Cibotari opened DATACASS-600 and commented

Hello , I have upgraded my Spring Boot 2.0.5 to 2.1.0.M4
After dependency upgrade I receive next error

The bean 'cassandraTemplate', defined in class path resource [org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [x/y/z/config/cassandra/CassandraConfiguration.class] and overriding is disabled

because of my

@Configuration
@EnableConfigurationProperties(CassandraProperties.class)
@EnableCassandraRepositories
public class CassandraConfiguration extends AbstractCassandraConfiguration

I can disable Auto configuration with

@SpringBootApplication(exclude = [CassandraDataAutoConfiguration::class])
class Application

I think Cassandra Auto Configuration needs to take care in consideration my AbstractCassandraConfiguration implementation


Affects: 2.0.10 (Kay SR10), 2.1 GA (Lovelace), 2.2 M1 (Moore)

Reference URL: spring-projects/spring-boot#14795

Referenced from: commits 514c4ba, 18f5025, 9e07f5b

Backported to: 2.1.1 (Lovelace SR1), 2.0.11 (Kay SR11)

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Oct 12, 2018

Mark Paluch commented

The issue is that AbstractCassandraConfiguration declares a cassandraTemplate(…) bean with the type CassandraAdminOperations that is the operations interface. Boot's auto-configuration really looks for CassandraTemplate (which is the actual implementation class) so we need to adjust our bean type to return CassandraAdminTemplate

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Oct 12, 2018

Mark Paluch commented

That's fixed now

@cmoonExpedia
Copy link

cmoonExpedia commented Jan 7, 2021

Hi, this problem is still happening in Springboot 2.4.1. :(

@SpringBootApplication(exclude = [CassandraDataAutoConfiguration::class])
@ConfigurationPropertiesScan
class Application @Autowired constructor(private val vertx: Vertx, private val serverVerticle: ServerVerticle) {

    @EventListener(ApplicationReadyEvent::class)
    fun deployVerticles() {
        vertx.deployVerticle(serverVerticle)
    }
}

@Bean
fun cassandraSession(@Autowired properties: CassandraProperties): Session {
    val builder = CqlSession.builder()
    properties.nodes.map { node -> builder.addContactPoint(InetSocketAddress(node, properties.port)) }
    builder.withLocalDatacenter(properties.localDatacenter)
    return builder.build()
}

Error message,

***************************
APPLICATION FAILED TO START
***************************

Description:

The bean 'cassandraSession', defined in class path resource [org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [com/hs/rippluence/configuration/AppConfig.class] and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true

@mp911de
Copy link
Member

mp911de commented Jan 7, 2021

@cmoonExpedia Spring Boot 2.3.x and newer uses the new Cassandra Driver 4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core type: bug
Projects
None yet
Development

No branches or pull requests

3 participants