运行Spring boot cassandra项目时遇到异常

时间:2016-02-21 05:11:00

标签: cassandra spring-boot

我通过为web,安全性,验证和spring-boot cassandra选择了一些依赖项来下载spring initializer项目。当我尝试运行./gradlew bootrun时,我在启动时遇到以下异常

  

org.springframework.beans.factory.BeanCreationException:创建名称为' session'的bean时出错在类路径资源中定义[org / springframework / boot / autoconfigure / data / cassandra / CassandraDataAutoConfiguration.class]:调用init方法失败;嵌套异常是com.datastax.driver.core.exceptions.NoHostAvailableException:所有尝试查询的主机都失败了(尝试过:localhost / 127.0.0.1:9042(com.datastax.driver.core.exceptions.InvalidQueryException:unconfigured table schema_keyspaces ))       在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)〜[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]       在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)〜[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]       在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)〜[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]       at org.springframework.beans.factory.support.AbstractBeanFactory $ 1.getObject(AbstractBeanFactory.java:306)〜[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]       在org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)〜[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]       在org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)〜[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]       在org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)〜[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]       at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java [spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]       在org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)〜[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]       在org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)〜[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]       at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)~ [spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]       在org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766)[spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]       在org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361)[spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]       在org.springframework.boot.SpringApplication.run(SpringApplication.java:307)[spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]       在org.springframework.boot.SpringApplication.run(SpringApplication.java:1191)[spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]       在org.springframework.boot.SpringApplication.run(SpringApplication.java:1180)[spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]       在com.anirudh.myretail.CassandratestApplication.main(CassandratestApplication.java:10)[main /:na]   引起:com.datastax.driver.core.exceptions.NoHostAvailableException:尝试查询失败的所有主机(尝试:localhost / 127.0.0.1:9042(com.datastax.driver.core.exceptions.InvalidQueryException:unconfigured table schema_keyspaces) ))       在com.datastax.driver.core.ControlConnection.reconnectInternal(ControlConnection.java:240)〜[cassandra-driver-core-2.1.9.jar:na]       在com.datastax.driver.core.ControlConnection.connect(ControlConnection.java:86)〜[cassandra-driver-core-2.1.9.jar:na]       在com.datastax.driver.core.Cluster $ Manager.init(Cluster.java:1429)〜[cassandra-driver-core-2.1.9.jar:na]       在com.datastax.driver.core.Cluster.init(Cluster.java:162)〜[cassandra-driver-core-2.1.9.jar:na]       在com.datastax.driver.core..connectAsync(Cluster.java:341)〜[cassandra-driver-core-2.1.9.jar:na]       在com.datastax.driver.core.Cluster.connectAsync(Cluster.java:314)〜[cassandra-driver-core-2.1.9.jar:na]       在com.datastax.driver.core.Cluster.connect(Cluster.java:252)〜[cassandra-driver-core-2.1.9.jar:na]       在org.springframework.cassandra.config.CassandraCqlSessionFactoryBean.afterPropertiesSet(CassandraCqlSessionFactoryBean.java:82)〜[spring-cql-1.3.2.RELEASE.jar:na]       在org.springframework.data.cassandra.config.CassandraSessionFactoryBean.afterPropertiesSet(CassandraSessionFactoryBean.java:43)〜[spring-data-cassandra-1.3.2.RELEASE.jar:na]       在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)〜[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]       在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)〜[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]

1 个答案:

答案 0 :(得分:8)

  

com.datastax.driver.core.exceptions.InvalidQueryException:unconfigured table schema_keyspaces

Cassandra Java Driver Spring Data正在使用 2.1.9

您正在使用的Cassandra版本可能 3.x 。自 3.x 以来,所有元数据都已移至关键空间 system_schema

您的问题的解决方案是:

  • 将您的版本降级为Cassandra 2.2.x 2.1.x
  • 等待Spring Data Cassandra将驱动程序版本升级到 的 3.0.0
  • 如果您不想等,请使用Achilles 5.2.0作为对象 支持Cassandra 3.x 的映射器。 注意:我是 Achilles 的创建者
  • 如果您不想等,请使用driver-mapper模块 附带Cassandra Java Driver