spring-projects / spring-data-cassandra

Provides support to increase developer productivity in Java when using Apache Cassandra. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.
https://spring.io/projects/spring-data-cassandra/
Apache License 2.0
381 stars 311 forks source link

Fails to find bean [DATACASS-345] #495

Closed spring-projects-issues closed 6 years ago

spring-projects-issues commented 8 years ago

Wali Usmani opened DATACASS-345 and commented

I have a bean defined in CassandraConfig (extends AbstractCassandraConfiguration)

@Bean
   public CassandraAdminOperations cassandraTemplate() throws Exception {
       return new CassandraAdminTemplate(session().getObject(), cassandraConverter());
   }

In the spring rest controller I am using :

@Autowired
    private CassandraAdminOperations adminTemplate;

Running Application gives me this error :

***************************
APPLICATION FAILED TO START
***************************

Description:

Field adminTemplate in com.health2047.authentication.service.AuthenticationService required a bean of type 'org.springframework.data.cassandra.core.CassandraAdminOperations' that could not be found.

Action:

Consider defining a bean of type 'org.springframework.data.cassandra.core.CassandraAdminOperations' in your configuration.

During debug, we saw that bean definition never gets called


Affects: 1.5 M1 (Ingalls)

spring-projects-issues commented 8 years ago

Mark Paluch commented

This issue seems to be more generic than Spring Data Cassandra-specific. Please make sure that your CassandraConfig class is annotated with @Configuration and that your configuration class is registered in your Spring Context

spring-projects-issues commented 8 years ago

Mark Paluch commented

Closing because of lacking feedback

spring-projects-issues commented 6 years ago

David commented

i had same issue, in my case it is fixed by renaming the method:

@Bean
public CassandraAdminOperations cassandraAdminOperations() throws Exception {
     return new CassandraAdminTemplate(session().getObject(), cassandraConverter());
}