亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

無法使用 CassandraConfiguration 連接到 cassandra

無法使用 CassandraConfiguration 連接到 cassandra

LEATH 2023-03-23 15:28:08
我已經按照 CassandraOperations 將記錄插入到 cassandra 中。因為我需要為一行插入 TTL 值,所以我選擇了這種方式。CrudRespository 不能有存儲 TTL 值的功能。下面是 Cassandra 配置類@Override@Beanpublic CassandraClusterFactoryBean cluster() {    final CassandraClusterFactoryBean cluster = new CassandraClusterFactoryBean();    cluster.setContactPoints(cassandra_contactPoints);    cluster.setPort(Integer.parseInt(cassandra_port));    cluster.setUsername(cassandra_username);    cluster.setPassword(cassandra_password);    LOGGER.info("Cluster created with contact points [" + cassandra_port + "] " + "& port ["            + Integer.parseInt(cassandra_port) + "].");    return cluster;}@Override@Beanpublic CassandraMappingContext cassandraMapping() throws ClassNotFoundException {    return new BasicCassandraMappingContext();}@Overrideprotected String getKeyspaceName() {    return cassandra_keyspaceName;}當我啟動應用程序時,它拋出以下異常Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.cassandra.core.CassandraAdminTemplate]: Factory method 'cassandraTemplate' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [com/sample/session/config/CassandraConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.cassandra.SessionFactory]: Factory method 'sessionFactory' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'session' defined in class path resource [com/sample/session/config/CassandraConfig.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: com/codahale/metrics/JmxReporter 
查看完整描述

1 回答

?
藍山帝景

TA貢獻1843條經驗 獲得超7個贊

這記錄在Java 驅動程序的文檔中——您需要創建一個沒有 JMX 指標報告的集群對象——這是通過添加.withoutJMXReporting()對集群構建器的調用或添加 Maven 依賴項來完成的:

<dependency>

  <groupId>io.dropwizard.metrics</groupId>

  <artifactId>metrics-jmx</artifactId>

  <version>4.0.2</version>

</dependency>


查看完整回答
反對 回復 2023-03-23
  • 1 回答
  • 0 關注
  • 103 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號