作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我按照 CassandraOperations 将记录插入到 cassandra 中。由于我需要插入一行的 TTL 值,所以我选择了这种方式。 CrudRespository不具备存储TTL值的功能。
下面是 Cassandra 配置类
@Override
@Bean
public 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
@Bean
public CassandraMappingContext cassandraMapping() throws ClassNotFoundException {
return new BasicCassandraMappingContext();
}
@Override
protected 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
Caused by: 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
Caused by: 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
Caused by: java.lang.ClassNotFoundException: com.codahale.metrics.JmxReporter
最佳答案
这记录在Java driver's documentation中- 您需要创建一个没有 JMX 指标报告的集群对象 - 这是通过将调用 .withoutJMXReporting()
添加到集群构建器来完成的,或者添加 Maven 依赖项:
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-jmx</artifactId>
<version>4.0.2</version>
</dependency>
关于java - 无法使用 CassandraConfiguration 连接到 cassandra,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57002356/
我正在开发一个 voip 调用应用程序。我需要做的是在接到来电时将 Activity 带到前台。我在应用程序中使用 Twilio,并在收到推送消息时开始调用。 问题是我试图在接到任何电话时显示 Act
我是一名优秀的程序员,十分优秀!