The project also depends on DataStax Cassandra drivers 4.9.0 and 3.10.2. Notice, DataStax Cassandra Driver 4.x and 3.x are binary incompatible and share different classpath. They don't conflict and thus both versions can be included in the same project. Out project must include both versions because some dependencies depend on one version and other dependencies depend on another version. Moreover, the project directly depend on 3.10.2 version.
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 [x/y/z/configuration/ColumnDatabaseConfiguration.class] and overriding is disabled.
As seen above, we excluded spring-data-cassandra from dependencies but it still tries to autoconfigure Cassandra beans.
We also tried to exclude Spring cassandra configuration classes but they are still being used:
spring-projects-issues commentedNov 13, 2020
porunov opened DATACASS-826 and commented
The project depends on Spring Boot Starter Web
compile ("org.springframework.boot:spring-boot-starter-web:2.3.2.RELEASE") {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
exclude group: 'junit', module: 'junit'
exclude group: 'org.springframework.data', module: 'spring-data-cassandra-parent'
exclude group: 'org.springframework.data', module: 'spring-data-cassandra'
exclude group: 'com.datastax.oss', module: 'java-driver-core'
}
compile ("org.springframework.boot:spring-boot-starter-data-jpa:2.3.2.RELEASE") {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
exclude group: 'junit', module: 'junit'
exclude group: 'org.springframework.data', module: 'spring-data-cassandra-parent'
exclude group: 'org.springframework.data', module: 'spring-data-cassandra'
exclude group: 'com.datastax.oss', module: 'java-driver-core'
}
compile ("org.springframework:spring-aop:5.2.8.RELEASE") {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
exclude group: 'junit', module: 'junit'
exclude group: 'org.springframework.data', module: 'spring-data-cassandra-parent'
exclude group: 'org.springframework.data', module: 'spring-data-cassandra'
exclude group: 'com.datastax.oss', module: 'java-driver-core'
}
compile ("org.springframework:spring-aspects:5.2.8.RELEASE") {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
exclude group: 'junit', module: 'junit'
exclude group: 'org.springframework.data', module: 'spring-data-cassandra-parent'
exclude group: 'org.springframework.data', module: 'spring-data-cassandra'
exclude group: 'com.datastax.oss', module: 'java-driver-core'
}
The project also depends on DataStax Cassandra drivers 4.9.0 and 3.10.2. Notice, DataStax Cassandra Driver 4.x and 3.x are binary incompatible and share different classpath. They don't conflict and thus both versions can be included in the same project. Out project must include both versions because some dependencies depend on one version and other dependencies depend on another version. Moreover, the project directly depend on 3.10.2 version.
We include both drivers into the classpath:
compile ("com.datastax.cassandra:cassandra-driver-core:3.10.2"){
exclude group: 'com.github.jnr', module: 'jnr-ffi'
exclude group: 'com.github.jnr', module: 'jnr-posix'
exclude group: 'io.dropwizard.metrics', module: 'metrics-core'
exclude group: 'io.netty', module: 'netty-handler'
}
compile ("com.datastax.cassandra:cassandra-driver-mapping:3.10.2"){
exclude group: 'com.github.jnr', module: 'jnr-ffi'
exclude group: 'com.github.jnr', module: 'jnr-posix'
exclude group: 'io.dropwizard.metrics', module: 'metrics-core'
exclude group: 'io.netty', module: 'netty-handler'
}
compile ("com.datastax.cassandra:cassandra-driver-extras:3.10.2")
compile ("com.datastax.oss:java-driver-core:4.9.0")
compile ("com.datastax.oss:java-driver-query-builder:4.9.0")
Unfortunately, when we try to create a Session bean like this:
@Primary
@Bean
(destroyMethod = "close")public Session cassandraSession(Cluster cassandraCluster) {
return cassandraCluster.connect();
}
We receive an error:
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 [x/y/z/configuration/ColumnDatabaseConfiguration.class] and overriding is disabled.
As seen above, we excluded spring-data-cassandra from dependencies but it still tries to autoconfigure Cassandra beans.
We also tried to exclude Spring cassandra configuration classes but they are still being used:
@SpringBootApplication
(scanBasePackages = "x.y.z", exclude = {CassandraDataAutoConfiguration.class, CassandraReactiveDataAutoConfiguration.class})We also suspect that this behaviour might be caused by Spring Dependency Management Plugin.
buildscript {
dependencies {
classpath ("io.spring.gradle:dependency-management-plugin:1.0.9.RELEASE")
}
}
Or Spring Boot Gradle Plugin:
buildscript {
dependencies {
classpath ("org.springframework.boot:spring-boot-gradle-plugin:2.3.2.RELEASE")
}
}
Any workarounds / thoughts on how to disable automatic Cassandra Session Bean Creation is highly appreciated
No further details from DATACASS-826
The text was updated successfully, but these errors were encountered: