Spring 数据 Cassandra 应用程序在通过 spring 配置创建密钥空间后终止
Spring data Cassandra Application getting terminated after creating keyspace via spring configuration
我已经创建了 Spring 数据 Cassandra CRUD 应用程序。首次启动此应用程序时,它会自动终止并出现以下错误,但它会根据 CassandraConfig.java class.
中的配置创建 KEYSPACE
当运行第二次申请时,通过引用之前创建的Keyspace可以正常工作,并且能够顺利地进行CRUD操作。
尝试了不同的方法仍然不确定缺少什么。
Git 存储库:https://github.com/rahul-ghadge/spring-boot-cassandra-crud
版本:
Spring 启动:2.3.3.RELEASE
卡桑德拉:3.11.7
2020-08-24 16:23:16.979 INFO 9740 --- [ s1-io-1] c.d.o.d.i.core.channel.ChannelFactory : [s1] Failed to connect with protocol DSE_V1, retrying with V4
2020-08-24 16:23:21.854 WARN 9740 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'springBootCassandraCrudApplication': Unsatisfied dependency expressed through field 'superHeroRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'superHeroRepository' defined in com.arya.cassandra.repository.SuperHeroRepository defined in @EnableCassandraRepositories declared on SpringBootCassandraCrudApplication: Cannot resolve reference to bean 'cassandraTemplate' while setting bean property 'cassandraTemplate'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cassandraTemplate' defined in class path resource [com/arya/cassandra/config/CassandraConfig.class]: Bean instantiation via factory method failed; nested exception is 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 'cassandraSessionFactory' defined in class path resource [com/arya/cassandra/config/CassandraConfig.class]: Invocation of init method failed; nested exception is org.springframework.data.cassandra.CassandraUncategorizedException: Query; CQL [CREATE TABLE IF NOT EXISTS super_hero (age int, id bigint, name text, profession text, super_name text, super_powers frozen<super_powers>, PRIMARY KEY (id));]; Query timed out after PT2S; nested exception is com.datastax.oss.driver.api.core.DriverTimeoutException: Query timed out after PT2S
2020-08-24 16:23:21.927 WARN 9740 --- [ s1-io-2] c.d.o.d.i.core.cql.CqlRequestHandler : [s1|1780306540|0] Unexpected error while refreshing schema after DDL query, keeping previous version (CompletionException: com.datastax.oss.driver.api.core.connection.ClosedConnectionException: Channel was force-closed)
2020-08-24 16:23:21.927 WARN 9740 --- [ s1-io-2] c.d.o.d.i.c.control.ControlConnection : [s1] Unexpected error while refreshing schema for a SCHEMA_CHANGE event, keeping previous version (CompletionException: com.datastax.oss.driver.api.core.connection.ClosedConnectionException: Channel was force-closed)
2020-08-24 16:23:23.994 WARN 9740 --- [ s0-admin-0] c.d.o.d.i.core.session.DefaultSession : [s0] Error while closing com.datastax.oss.driver.internal.core.config.typesafe.DefaultDriverConfigLoader@1247f3f7 (RejectedExecutionException: event executor terminated)
2020-08-24 16:23:26.062 INFO 9740 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2020-08-24 16:23:26.094 INFO 9740 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-08-24 16:23:26.105 ERROR 9740 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'springBootCassandraCrudApplication': Unsatisfied dependency expressed through field 'superHeroRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'superHeroRepository' defined in com.arya.cassandra.repository.SuperHeroRepository defined in @EnableCassandraRepositories declared on SpringBootCassandraCrudApplication: Cannot resolve reference to bean 'cassandraTemplate' while setting bean property 'cassandraTemplate'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cassandraTemplate' defined in class path resource [com/arya/cassandra/config/CassandraConfig.class]: Bean instantiation via factory method failed; nested exception is 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 'cassandraSessionFactory' defined in class path resource [com/arya/cassandra/config/CassandraConfig.class]: Invocation of init method failed; nested exception is org.springframework.data.cassandra.CassandraUncategorizedException: Query; CQL [CREATE TABLE IF NOT EXISTS super_hero (age int, id bigint, name text, profession text, super_name text, super_powers frozen<super_powers>, PRIMARY KEY (id));]; Query timed out after PT2S; nested exception is com.datastax.oss.driver.api.core.DriverTimeoutException: Query timed out after PT2S
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:643) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:130) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1420) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean[=12=](AbstractBeanFactory.java:324) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:897) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:879) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at com.arya.cassandra.SpringBootCassandraCrudApplication.main(SpringBootCassandraCrudApplication.java:25) [classes/:na]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'superHeroRepository' defined in com.arya.cassandra.repository.SuperHeroRepository defined in @EnableCassandraRepositories declared on SpringBootCassandraCrudApplication: Cannot resolve reference to bean 'cassandraTemplate' while setting bean property 'cassandraTemplate'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cassandraTemplate' defined in class path resource [com/arya/cassandra/config/CassandraConfig.class]: Bean instantiation via factory method failed; nested exception is 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 'cassandraSessionFactory' defined in class path resource [com/arya/cassandra/config/CassandraConfig.class]: Invocation of init method failed; nested exception is org.springframework.data.cassandra.CassandraUncategorizedException: Query; CQL [CREATE TABLE IF NOT EXISTS super_hero (age int, id bigint, name text, profession text, super_name text, super_powers frozen<super_powers>, PRIMARY KEY (id));]; Query timed out after PT2S; nested exception is com.datastax.oss.driver.api.core.DriverTimeoutException: Query timed out after PT2S
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:342) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:113) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1697) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1442) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean[=12=](AbstractBeanFactory.java:324) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1307) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1227) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
... 20 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cassandraTemplate' defined in class path resource [com/arya/cassandra/config/CassandraConfig.class]: Bean instantiation via factory method failed; nested exception is 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 'cassandraSessionFactory' defined in class path resource [com/arya/cassandra/config/CassandraConfig.class]: Invocation of init method failed; nested exception is org.springframework.data.cassandra.CassandraUncategorizedException: Query; CQL [CREATE TABLE IF NOT EXISTS super_hero (age int, id bigint, name text, profession text, super_name text, super_powers frozen<super_powers>, PRIMARY KEY (id));]; Query timed out after PT2S; nested exception is com.datastax.oss.driver.api.core.DriverTimeoutException: Query timed out after PT2S
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:655) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:483) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1336) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1176) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:556) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean[=12=](AbstractBeanFactory.java:324) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:330) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
... 33 common frames omitted
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 'cassandraSessionFactory' defined in class path resource [com/arya/cassandra/config/CassandraConfig.class]: Invocation of init method failed; nested exception is org.springframework.data.cassandra.CassandraUncategorizedException: Query; CQL [CREATE TABLE IF NOT EXISTS super_hero (age int, id bigint, name text, profession text, super_name text, super_powers frozen<super_powers>, PRIMARY KEY (id));]; Query timed out after PT2S; nested exception is com.datastax.oss.driver.api.core.DriverTimeoutException: Query timed out after PT2S
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:650) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
... 43 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cassandraSessionFactory' defined in class path resource [com/arya/cassandra/config/CassandraConfig.class]: Invocation of init method failed; nested exception is org.springframework.data.cassandra.CassandraUncategorizedException: Query; CQL [CREATE TABLE IF NOT EXISTS super_hero (age int, id bigint, name text, profession text, super_name text, super_powers frozen<super_powers>, PRIMARY KEY (id));]; Query timed out after PT2S; nested exception is com.datastax.oss.driver.api.core.DriverTimeoutException: Query timed out after PT2S
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1794) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean[=12=](AbstractBeanFactory.java:324) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:227) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveNamedBean(DefaultListableBeanFactory.java:1175) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveBean(DefaultListableBeanFactory.java:420) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:350) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:343) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.data.cassandra.config.AbstractSessionConfiguration.requireBeanOfType(AbstractSessionConfiguration.java:100) ~[spring-data-cassandra-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.springframework.data.cassandra.config.AbstractCassandraConfiguration.getRequiredSessionFactory(AbstractCassandraConfiguration.java:215) ~[spring-data-cassandra-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.springframework.data.cassandra.config.AbstractCassandraConfiguration.cassandraTemplate(AbstractCassandraConfiguration.java:146) ~[spring-data-cassandra-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at com.arya.cassandra.config.CassandraConfig$$EnhancerBySpringCGLIB$e6d0aee.CGLIB$cassandraTemplate(<generated>) ~[classes/:na]
at com.arya.cassandra.config.CassandraConfig$$EnhancerBySpringCGLIB$e6d0aee$$FastClassBySpringCGLIB$$c9e88c5e.invoke(<generated>) ~[classes/:na]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at com.arya.cassandra.config.CassandraConfig$$EnhancerBySpringCGLIB$e6d0aee.cassandraTemplate(<generated>) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_191]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_191]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_191]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_191]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
... 44 common frames omitted
Caused by: org.springframework.data.cassandra.CassandraUncategorizedException: Query; CQL [CREATE TABLE IF NOT EXISTS super_hero (age int, id bigint, name text, profession text, super_name text, super_powers frozen<super_powers>, PRIMARY KEY (id));]; Query timed out after PT2S; nested exception is com.datastax.oss.driver.api.core.DriverTimeoutException: Query timed out after PT2S
at org.springframework.data.cassandra.core.cql.CassandraExceptionTranslator.translate(CassandraExceptionTranslator.java:160) ~[spring-data-cassandra-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.springframework.data.cassandra.core.cql.CassandraAccessor.translate(CassandraAccessor.java:379) ~[spring-data-cassandra-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.springframework.data.cassandra.core.cql.CqlTemplate.translateException(CqlTemplate.java:718) ~[spring-data-cassandra-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.springframework.data.cassandra.core.cql.CqlTemplate.query(CqlTemplate.java:173) ~[spring-data-cassandra-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.springframework.data.cassandra.core.cql.CqlTemplate.queryForResultSet(CqlTemplate.java:250) ~[spring-data-cassandra-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.springframework.data.cassandra.core.cql.CqlTemplate.execute(CqlTemplate.java:148) ~[spring-data-cassandra-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.springframework.data.cassandra.core.CassandraPersistentEntitySchemaCreator.lambda$createTables[=12=](CassandraPersistentEntitySchemaCreator.java:102) ~[spring-data-cassandra-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) ~[na:1.8.0_191]
at java.util.stream.ReferencePipeline.accept(ReferencePipeline.java:193) ~[na:1.8.0_191]
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382) ~[na:1.8.0_191]
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) ~[na:1.8.0_191]
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) ~[na:1.8.0_191]
at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) ~[na:1.8.0_191]
at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) ~[na:1.8.0_191]
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:1.8.0_191]
at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418) ~[na:1.8.0_191]
at org.springframework.data.cassandra.core.CassandraPersistentEntitySchemaCreator.createTables(CassandraPersistentEntitySchemaCreator.java:102) ~[spring-data-cassandra-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.springframework.data.cassandra.config.SessionFactoryFactoryBean.performSchemaActions(SessionFactoryFactoryBean.java:220) ~[spring-data-cassandra-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.springframework.data.cassandra.config.SessionFactoryFactoryBean.createTables(SessionFactoryFactoryBean.java:199) ~[spring-data-cassandra-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.springframework.data.cassandra.config.SessionFactoryFactoryBean.performSchemaAction(SessionFactoryFactoryBean.java:185) ~[spring-data-cassandra-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.springframework.data.cassandra.config.SessionFactoryFactoryBean.afterPropertiesSet(SessionFactoryFactoryBean.java:135) ~[spring-data-cassandra-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1853) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1790) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
... 67 common frames omitted
Caused by: com.datastax.oss.driver.api.core.DriverTimeoutException: Query timed out after PT2S
at com.datastax.oss.driver.api.core.DriverTimeoutException.copy(DriverTimeoutException.java:34) ~[java-driver-core-4.6.1.jar:na]
at com.datastax.oss.driver.internal.core.util.concurrent.CompletableFutures.getUninterruptibly(CompletableFutures.java:149) ~[java-driver-core-4.6.1.jar:na]
at com.datastax.oss.driver.internal.core.cql.CqlRequestSyncProcessor.process(CqlRequestSyncProcessor.java:53) ~[java-driver-core-4.6.1.jar:na]
at com.datastax.oss.driver.internal.core.cql.CqlRequestSyncProcessor.process(CqlRequestSyncProcessor.java:30) ~[java-driver-core-4.6.1.jar:na]
at com.datastax.oss.driver.internal.core.session.DefaultSession.execute(DefaultSession.java:230) ~[java-driver-core-4.6.1.jar:na]
at com.datastax.oss.driver.api.core.cql.SyncCqlSession.execute(SyncCqlSession.java:53) ~[java-driver-core-4.6.1.jar:na]
at org.springframework.data.cassandra.core.cql.CqlTemplate.query(CqlTemplate.java:169) ~[spring-data-cassandra-3.0.3.RELEASE.jar:3.0.3.RELEASE]
... 86 common frames omitted
Process finished with exit code 1
请帮忙。提前致谢。
将 spring-boot-starter-parent
版本降级到 2.2.7.RELEASE
后,它开始工作而没有终止应用程序,还创建了 KEYSPACE 和 TABLES 一口气
评论了来自 Cassandra 配置 class 的 getLocalDataCenter()
方法,它在 AbstractCassandraConfiguration
class.
中不存在
Spring Boot: 2.3.3.RELEASE (Not working as expected)
Cassandra : 3.11.7
Cassandra : 3.0.21
Spring Boot: 2.2.9.RELEASE (Not working as expected)
Cassandra : 3.11.7
Cassandra : 3.0.21
Spring Boot: 2.2.7.RELEASE (Working as expected)
Cassandra : 3.11.7
Cassandra : 3.0.21
工作代码被推送到新分支。
Git 存储库:https://github.com/rahul-ghadge/spring-boot-cassandra-crud/tree/working-2.2.7-bug-fix
需要查看官方文档,2.2之后有什么变化。7.RELEASE。
我已经创建了 Spring 数据 Cassandra CRUD 应用程序。首次启动此应用程序时,它会自动终止并出现以下错误,但它会根据 CassandraConfig.java class.
中的配置创建 KEYSPACE当运行第二次申请时,通过引用之前创建的Keyspace可以正常工作,并且能够顺利地进行CRUD操作。
尝试了不同的方法仍然不确定缺少什么。
Git 存储库:https://github.com/rahul-ghadge/spring-boot-cassandra-crud
版本:
Spring 启动:2.3.3.RELEASE
卡桑德拉:3.11.7
2020-08-24 16:23:16.979 INFO 9740 --- [ s1-io-1] c.d.o.d.i.core.channel.ChannelFactory : [s1] Failed to connect with protocol DSE_V1, retrying with V4
2020-08-24 16:23:21.854 WARN 9740 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'springBootCassandraCrudApplication': Unsatisfied dependency expressed through field 'superHeroRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'superHeroRepository' defined in com.arya.cassandra.repository.SuperHeroRepository defined in @EnableCassandraRepositories declared on SpringBootCassandraCrudApplication: Cannot resolve reference to bean 'cassandraTemplate' while setting bean property 'cassandraTemplate'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cassandraTemplate' defined in class path resource [com/arya/cassandra/config/CassandraConfig.class]: Bean instantiation via factory method failed; nested exception is 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 'cassandraSessionFactory' defined in class path resource [com/arya/cassandra/config/CassandraConfig.class]: Invocation of init method failed; nested exception is org.springframework.data.cassandra.CassandraUncategorizedException: Query; CQL [CREATE TABLE IF NOT EXISTS super_hero (age int, id bigint, name text, profession text, super_name text, super_powers frozen<super_powers>, PRIMARY KEY (id));]; Query timed out after PT2S; nested exception is com.datastax.oss.driver.api.core.DriverTimeoutException: Query timed out after PT2S
2020-08-24 16:23:21.927 WARN 9740 --- [ s1-io-2] c.d.o.d.i.core.cql.CqlRequestHandler : [s1|1780306540|0] Unexpected error while refreshing schema after DDL query, keeping previous version (CompletionException: com.datastax.oss.driver.api.core.connection.ClosedConnectionException: Channel was force-closed)
2020-08-24 16:23:21.927 WARN 9740 --- [ s1-io-2] c.d.o.d.i.c.control.ControlConnection : [s1] Unexpected error while refreshing schema for a SCHEMA_CHANGE event, keeping previous version (CompletionException: com.datastax.oss.driver.api.core.connection.ClosedConnectionException: Channel was force-closed)
2020-08-24 16:23:23.994 WARN 9740 --- [ s0-admin-0] c.d.o.d.i.core.session.DefaultSession : [s0] Error while closing com.datastax.oss.driver.internal.core.config.typesafe.DefaultDriverConfigLoader@1247f3f7 (RejectedExecutionException: event executor terminated)
2020-08-24 16:23:26.062 INFO 9740 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2020-08-24 16:23:26.094 INFO 9740 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-08-24 16:23:26.105 ERROR 9740 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'springBootCassandraCrudApplication': Unsatisfied dependency expressed through field 'superHeroRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'superHeroRepository' defined in com.arya.cassandra.repository.SuperHeroRepository defined in @EnableCassandraRepositories declared on SpringBootCassandraCrudApplication: Cannot resolve reference to bean 'cassandraTemplate' while setting bean property 'cassandraTemplate'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cassandraTemplate' defined in class path resource [com/arya/cassandra/config/CassandraConfig.class]: Bean instantiation via factory method failed; nested exception is 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 'cassandraSessionFactory' defined in class path resource [com/arya/cassandra/config/CassandraConfig.class]: Invocation of init method failed; nested exception is org.springframework.data.cassandra.CassandraUncategorizedException: Query; CQL [CREATE TABLE IF NOT EXISTS super_hero (age int, id bigint, name text, profession text, super_name text, super_powers frozen<super_powers>, PRIMARY KEY (id));]; Query timed out after PT2S; nested exception is com.datastax.oss.driver.api.core.DriverTimeoutException: Query timed out after PT2S
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:643) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:130) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1420) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean[=12=](AbstractBeanFactory.java:324) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:897) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:879) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at com.arya.cassandra.SpringBootCassandraCrudApplication.main(SpringBootCassandraCrudApplication.java:25) [classes/:na]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'superHeroRepository' defined in com.arya.cassandra.repository.SuperHeroRepository defined in @EnableCassandraRepositories declared on SpringBootCassandraCrudApplication: Cannot resolve reference to bean 'cassandraTemplate' while setting bean property 'cassandraTemplate'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cassandraTemplate' defined in class path resource [com/arya/cassandra/config/CassandraConfig.class]: Bean instantiation via factory method failed; nested exception is 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 'cassandraSessionFactory' defined in class path resource [com/arya/cassandra/config/CassandraConfig.class]: Invocation of init method failed; nested exception is org.springframework.data.cassandra.CassandraUncategorizedException: Query; CQL [CREATE TABLE IF NOT EXISTS super_hero (age int, id bigint, name text, profession text, super_name text, super_powers frozen<super_powers>, PRIMARY KEY (id));]; Query timed out after PT2S; nested exception is com.datastax.oss.driver.api.core.DriverTimeoutException: Query timed out after PT2S
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:342) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:113) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1697) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1442) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean[=12=](AbstractBeanFactory.java:324) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1307) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1227) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
... 20 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cassandraTemplate' defined in class path resource [com/arya/cassandra/config/CassandraConfig.class]: Bean instantiation via factory method failed; nested exception is 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 'cassandraSessionFactory' defined in class path resource [com/arya/cassandra/config/CassandraConfig.class]: Invocation of init method failed; nested exception is org.springframework.data.cassandra.CassandraUncategorizedException: Query; CQL [CREATE TABLE IF NOT EXISTS super_hero (age int, id bigint, name text, profession text, super_name text, super_powers frozen<super_powers>, PRIMARY KEY (id));]; Query timed out after PT2S; nested exception is com.datastax.oss.driver.api.core.DriverTimeoutException: Query timed out after PT2S
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:655) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:483) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1336) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1176) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:556) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean[=12=](AbstractBeanFactory.java:324) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:330) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
... 33 common frames omitted
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 'cassandraSessionFactory' defined in class path resource [com/arya/cassandra/config/CassandraConfig.class]: Invocation of init method failed; nested exception is org.springframework.data.cassandra.CassandraUncategorizedException: Query; CQL [CREATE TABLE IF NOT EXISTS super_hero (age int, id bigint, name text, profession text, super_name text, super_powers frozen<super_powers>, PRIMARY KEY (id));]; Query timed out after PT2S; nested exception is com.datastax.oss.driver.api.core.DriverTimeoutException: Query timed out after PT2S
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:650) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
... 43 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cassandraSessionFactory' defined in class path resource [com/arya/cassandra/config/CassandraConfig.class]: Invocation of init method failed; nested exception is org.springframework.data.cassandra.CassandraUncategorizedException: Query; CQL [CREATE TABLE IF NOT EXISTS super_hero (age int, id bigint, name text, profession text, super_name text, super_powers frozen<super_powers>, PRIMARY KEY (id));]; Query timed out after PT2S; nested exception is com.datastax.oss.driver.api.core.DriverTimeoutException: Query timed out after PT2S
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1794) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean[=12=](AbstractBeanFactory.java:324) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:227) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveNamedBean(DefaultListableBeanFactory.java:1175) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveBean(DefaultListableBeanFactory.java:420) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:350) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:343) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.data.cassandra.config.AbstractSessionConfiguration.requireBeanOfType(AbstractSessionConfiguration.java:100) ~[spring-data-cassandra-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.springframework.data.cassandra.config.AbstractCassandraConfiguration.getRequiredSessionFactory(AbstractCassandraConfiguration.java:215) ~[spring-data-cassandra-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.springframework.data.cassandra.config.AbstractCassandraConfiguration.cassandraTemplate(AbstractCassandraConfiguration.java:146) ~[spring-data-cassandra-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at com.arya.cassandra.config.CassandraConfig$$EnhancerBySpringCGLIB$e6d0aee.CGLIB$cassandraTemplate(<generated>) ~[classes/:na]
at com.arya.cassandra.config.CassandraConfig$$EnhancerBySpringCGLIB$e6d0aee$$FastClassBySpringCGLIB$$c9e88c5e.invoke(<generated>) ~[classes/:na]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at com.arya.cassandra.config.CassandraConfig$$EnhancerBySpringCGLIB$e6d0aee.cassandraTemplate(<generated>) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_191]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_191]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_191]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_191]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
... 44 common frames omitted
Caused by: org.springframework.data.cassandra.CassandraUncategorizedException: Query; CQL [CREATE TABLE IF NOT EXISTS super_hero (age int, id bigint, name text, profession text, super_name text, super_powers frozen<super_powers>, PRIMARY KEY (id));]; Query timed out after PT2S; nested exception is com.datastax.oss.driver.api.core.DriverTimeoutException: Query timed out after PT2S
at org.springframework.data.cassandra.core.cql.CassandraExceptionTranslator.translate(CassandraExceptionTranslator.java:160) ~[spring-data-cassandra-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.springframework.data.cassandra.core.cql.CassandraAccessor.translate(CassandraAccessor.java:379) ~[spring-data-cassandra-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.springframework.data.cassandra.core.cql.CqlTemplate.translateException(CqlTemplate.java:718) ~[spring-data-cassandra-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.springframework.data.cassandra.core.cql.CqlTemplate.query(CqlTemplate.java:173) ~[spring-data-cassandra-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.springframework.data.cassandra.core.cql.CqlTemplate.queryForResultSet(CqlTemplate.java:250) ~[spring-data-cassandra-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.springframework.data.cassandra.core.cql.CqlTemplate.execute(CqlTemplate.java:148) ~[spring-data-cassandra-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.springframework.data.cassandra.core.CassandraPersistentEntitySchemaCreator.lambda$createTables[=12=](CassandraPersistentEntitySchemaCreator.java:102) ~[spring-data-cassandra-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) ~[na:1.8.0_191]
at java.util.stream.ReferencePipeline.accept(ReferencePipeline.java:193) ~[na:1.8.0_191]
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382) ~[na:1.8.0_191]
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) ~[na:1.8.0_191]
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) ~[na:1.8.0_191]
at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) ~[na:1.8.0_191]
at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) ~[na:1.8.0_191]
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:1.8.0_191]
at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418) ~[na:1.8.0_191]
at org.springframework.data.cassandra.core.CassandraPersistentEntitySchemaCreator.createTables(CassandraPersistentEntitySchemaCreator.java:102) ~[spring-data-cassandra-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.springframework.data.cassandra.config.SessionFactoryFactoryBean.performSchemaActions(SessionFactoryFactoryBean.java:220) ~[spring-data-cassandra-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.springframework.data.cassandra.config.SessionFactoryFactoryBean.createTables(SessionFactoryFactoryBean.java:199) ~[spring-data-cassandra-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.springframework.data.cassandra.config.SessionFactoryFactoryBean.performSchemaAction(SessionFactoryFactoryBean.java:185) ~[spring-data-cassandra-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.springframework.data.cassandra.config.SessionFactoryFactoryBean.afterPropertiesSet(SessionFactoryFactoryBean.java:135) ~[spring-data-cassandra-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1853) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1790) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
... 67 common frames omitted
Caused by: com.datastax.oss.driver.api.core.DriverTimeoutException: Query timed out after PT2S
at com.datastax.oss.driver.api.core.DriverTimeoutException.copy(DriverTimeoutException.java:34) ~[java-driver-core-4.6.1.jar:na]
at com.datastax.oss.driver.internal.core.util.concurrent.CompletableFutures.getUninterruptibly(CompletableFutures.java:149) ~[java-driver-core-4.6.1.jar:na]
at com.datastax.oss.driver.internal.core.cql.CqlRequestSyncProcessor.process(CqlRequestSyncProcessor.java:53) ~[java-driver-core-4.6.1.jar:na]
at com.datastax.oss.driver.internal.core.cql.CqlRequestSyncProcessor.process(CqlRequestSyncProcessor.java:30) ~[java-driver-core-4.6.1.jar:na]
at com.datastax.oss.driver.internal.core.session.DefaultSession.execute(DefaultSession.java:230) ~[java-driver-core-4.6.1.jar:na]
at com.datastax.oss.driver.api.core.cql.SyncCqlSession.execute(SyncCqlSession.java:53) ~[java-driver-core-4.6.1.jar:na]
at org.springframework.data.cassandra.core.cql.CqlTemplate.query(CqlTemplate.java:169) ~[spring-data-cassandra-3.0.3.RELEASE.jar:3.0.3.RELEASE]
... 86 common frames omitted
Process finished with exit code 1
请帮忙。提前致谢。
将 spring-boot-starter-parent
版本降级到 2.2.7.RELEASE
后,它开始工作而没有终止应用程序,还创建了 KEYSPACE 和 TABLES 一口气
评论了来自 Cassandra 配置 class 的 getLocalDataCenter()
方法,它在 AbstractCassandraConfiguration
class.
Spring Boot: 2.3.3.RELEASE (Not working as expected)
Cassandra : 3.11.7
Cassandra : 3.0.21
Spring Boot: 2.2.9.RELEASE (Not working as expected)
Cassandra : 3.11.7
Cassandra : 3.0.21
Spring Boot: 2.2.7.RELEASE (Working as expected)
Cassandra : 3.11.7
Cassandra : 3.0.21
工作代码被推送到新分支。
Git 存储库:https://github.com/rahul-ghadge/spring-boot-cassandra-crud/tree/working-2.2.7-bug-fix
需要查看官方文档,2.2之后有什么变化。7.RELEASE。