Spring Boot 2.3.0.M4、Cassandra 和 SSL [英] Spring Boot 2.3.0.M4, Cassandra, and SSL
问题描述
我一直在使用 ClusterBuilderCustomizer
来自定义 Spring Boot 应用程序 (2.2.5.RELEASE) 和 Cassandra 数据库之间的 SSL 连接.迁移到 Spring Boot 2.3.0.M4 后,我的代码不再编译,因为 ClusterBuilderCustomizer
不再存在.
I have been using ClusterBuilderCustomizer
to customize the SSL connection between my Spring Boot application (2.2.5.RELEASE) and the Cassandra database. After migrating to Spring Boot 2.3.0.M4, my code no longer compiles as the ClusterBuilderCustomizer
doesn't exist anymore.
根据 SpringBoot 2.3.0 发行说明,已替换为 DriverConfigLoaderBuilderCustomizer
和 CqlSessionBuilderCustomizer
.有没有人有关于如何将这些自定义程序类与 SSL 结合使用的示例?
As per Spring Boot 2.3.0 release notes, it has been replaced with DriverConfigLoaderBuilderCustomizer
and CqlSessionBuilderCustomizer
. Does anyone have a working example on how to use any of these customizer classes with SSL?
推荐答案
你只需要声明两个具有以下类型的 bean:
You just need to declare two beans having these types:
@Bean
public CqlSessionBuilderCustomizer cqlSessionBuilderCustomizer() {
return cqlSessionBuilder -> cqlSessionBuilder
.withNodeStateListener(new MyNodeStateListener())
.withSchemaChangeListener(new MySchemChangeListener());
}
@Bean
public DriverConfigLoaderBuilderCustomizer driverConfigLoaderBuilderCustomizer() {
return loaderBuilder -> loaderBuilder
.withDuration(DefaultDriverOption.REQUEST_TIMEOUT, Duration.ofSeconds(10));
}
}
使用 CqlSessionBuilderCustomizer
将运行时对象传递给会话构建器,例如节点状态侦听器或架构更改侦听器.
Use CqlSessionBuilderCustomizer
to pass runtime objects to the session builder, e.g. node state listeners or schema change listeners.
使用 DriverConfigLoaderBuilderCustomizer
以编程方式自定义驱动程序配置.请参阅驱动程序文档 有关如何以编程方式配置驱动程序的更多信息.
Use DriverConfigLoaderBuilderCustomizer
to programmatically customize the driver configuration. See the driver docs for more information on how to programmatically configure the driver.
这篇关于Spring Boot 2.3.0.M4、Cassandra 和 SSL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!