我試圖使用spring-data-cassandra(1.2.0.BUILD-SNAPSHOT)創建獨立的應用程序。 當嘗試使用下面的異常被拋出 (我的context.xml是here)在設置bean屬性'cassandraTemplate'時無法解析對bean'cqlTemplate'的引用'
讚賞我做錯了其中任何提示「新的ClassPathXmlApplicationContext(‘context.xml中’)」創建應用程序上下文 。
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'personRepository': Cannot resolve reference to bean 'cqlTemplate' while setting bean property 'cassandraTemplate'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'cqlTemplate' is defined
\t at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:336)
\t at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
\t at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1457)
\t at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1198)
\t at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
\t at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
\t at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
\t at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
\t at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
\t at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
\t at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:687)
\t at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:762)
\t at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
\t at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
\t at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
\t at com.nosql.MainApp.search(MainApp.java:20)
\t at com.nosql.MainApp.main(MainApp.java:26)
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'cqlTemplate' is defined
\t at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:641)
\t at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1157)
\t at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:280)
\t at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
\t at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
\t ... 16 more
2014-11-03 15:50:07,147 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Retrieved dependent beans for bean '(inner bean)#2e5d4162': [cassandraCluster]
P.S: - 從來沒有使用過春天。
是這個問題解決了,我面臨着類似的問題在我的獨立應用程序,其中應用程序啓動它失敗了同樣的錯誤。我正在嘗試使用Cassandra存儲庫中的Spring Data。 – 2015-03-24 18:43:42
是的,創建了cqlTemplate bean,如下所示:http://docs.spring.io/spring-data/cassandra/docs/1.0.1.RELEASE/reference/html/cassandra.core.html#cassandra-connectors.xmlconfig – dwingle 2015-12-19 07:46:55