3
votes

I am trying to connect to Cassandra from my Spring boot application using spring-boot-data-cassandra.I have two doubts.

1) Is it recommended to use the CassandraAutoConfiguration i.e. by providing all Cassandra configurations in application.properties with prefix(spring.data.cassandra.*) so that my app will create a cluster for me or do I need to manually create cluster bean, because in CassandraAutoConfiguration cluster bean is annotated with @ConditionalOnMissingBeanso which one is more preferred to use spring cassandra auto configuration or manually creating a cluster bean.

2) My cluster is enabled with ssl at Cassandra side. So when I am auto configuring Cassandra connections with ssl enabled (by setting spring.data.cassandra.ssl=true) then Default SSL context is created for me, but i need to provide my truststore path and truststore password to initialize SSLContext. There is no properties provided at data-cassandra like the one provided for kafka(spring.kafka.ssl.truststore-location= # Location of the trust store file. spring.kafka.ssl.truststore-password= # Store password for the trust store file.), so is there any way to provide truststore file location and password to AutoConfigure my Cassandra configuration or to override default SSLContext created.

Please help me and correct me if my understanding is wrong. Thanks.

Updates:

https://github.com/spring-projects/spring-boot/issues/8476

1
how did you solve this?Hasson

1 Answers

0
votes

Using Spring Boot's Auto-Configuration is the preferred approach but Boot goes out of your way if you need to apply a more specific configuration. Most conditional beans are created if there's no other provided @Bean.

If you provide Cluster yourself, then Spring Boot's Auto-Configuration will not provide a second Cluster bean.

The preferred approach since Spring Boot 1.5, if you need a more specific configuration, is providing a ClusterBuilderCustomizer bean that gets called to customize Cluster.Builder to your needs.

You might also want to file an issue in Spring Boot's issue tracker. Specific SSL configuration is a common configuration use-case.