【问题标题】:override spring-data-cassandra SchemaAction覆盖 spring-data-cassandra SchemaAction
【发布时间】:2015-01-31 04:33:05
【问题描述】:

我将如何覆盖AbstractCassandraConfiguration 以使用我自己的函数来创建架构。我希望能够使用我在运行时选择的 cql 脚本来设置 Cassandra 实例。

CassandraSessionFactoryBean.performSchemaAction()AbstractCassandraConfiguration.session() 中创建时,我试图覆盖它。这会导致 cqllib 失败并显示

java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given

这似乎与 cqlib 如何创建代理有关:Superclass has no null constructors but no arguments were given

【问题讨论】:

    标签: spring-data-cassandra


    【解决方案1】:

    您可以在AbstractCassandraConfiguration 中覆盖getStartupScripts()。在那里,你可以做任何你想做的事。它被CassandraCqlClusterFactoryBeanexecuteSpecsAndScripts 方法(在afterPropertiesSet 中调用)使用。

    【讨论】:

    • 嗯,这可能行得通。我可以在这个方法中查询我的集群吗?
    • 该方法允许您执行任意 CQL 脚本(作为 List<String>)。做任何你想做的事。
    • 这需要注意一点,如果我需要基于集群当前状态的任何逻辑,我需要直接使用 Datastax 驱动程序。
    猜你喜欢
    • 2021-02-07
    • 2018-06-25
    • 2020-08-07
    • 1970-01-01
    • 1970-01-01
    • 2012-10-13
    • 2014-06-05
    • 2019-07-23
    • 1970-01-01
    相关资源
    最近更新 更多