[Resolved] NoSuchBeanDefinitionException: No bean named 'cqlTemplate' available - DevDummy

Latest

Coding Hacks, Shared ...

Monday, November 06, 2017

[Resolved] NoSuchBeanDefinitionException: No bean named 'cqlTemplate' available






Cassandra Exception

In Spring Data Cassandra integration to the project, you may have setup the cassandra context as follows,

   <cassandra:template id="cassandraTemplate" />

    <!-- OPTIONAL: If you are using Spring Data for Apache Cassandra Repositories, add your base packages to scan here -->
    <cassandra:repositories  ...

The Issue

And may still noticing the following error,

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'cqlTemplate' available
 at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:687)
 at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1207)
 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:284)
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
 at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351)

Resolution

The issue here is, even though the Cassandra template is available in the context, it is not noticed while repository operations happen.

The issue can be resolved by setting the template to the repository.

<cassandra:repositories ...   cassandra-template-ref="cassandraTemplate" />

References



No comments:

Post a Comment