0

I have started working with Spring framework. Here I am working with Spring Data - Cassandra Repository modular application. I could able to test a spring-data-cassandra application individually, whereas when I try to use as a moudle in a project and scan the packages of components from other module like...

<context:component-scan base-package="example.dao,example.domain" />

I am getting an error

No qualifying bean of type [example.domain.EventRepository] found for dependency [example.domain.EventRepository]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}

I can share you the code, if required.

The way I have done for another modules works fine.

I am not getting where is the problem.

Please find the code below for DAO CLASS.

@Service 
@Transactional
public class EventDao {

@Autowired
private EventRepository eventRepository;

/*public EventDao(EventRepository eventRepository) {

    this.eventRepository = eventRepository;
}*/

private final static Logger logger = LoggerFactory.getLogger(EventDao.class);

public Event saveMember(Event member) {
    eventRepository.save(member);

    return member;
}
}

My Repository interface.

package example.domain;

import org.springframework.data.cassandra.repository.CassandraRepository;
import org.springframework.data.cassandra.repository.Query;

public interface EventRepository extends CassandraRepository<Event> {

@Query("select * from event where type = ?0 and bucket=?1")
Iterable<Event> findByTypeAndBucket(String type, String bucket);
}

My Cassandra configuration class.

package example;


@Configuration
@PropertySource(value = { "classpath:cassandra.properties" })
@EnableCassandraRepositories(basePackages = { "example" })
 public class CassandraConfiguration extends AbstractCassandraConfiguration {

private static final Logger LOG = LoggerFactory.getLogger(CassandraConfiguration.class);

@Autowired
private Environment environment;

@Bean
public CassandraClusterFactoryBean cluster() {
    CassandraClusterFactoryBean cluster = new CassandraClusterFactoryBean();
    cluster.setContactPoints(environment.getProperty("cassandra.contactpoints"));
    cluster.setPort(Integer.parseInt(environment.getProperty("cassandra.port")));
    return cluster;
}

@Override
protected String getKeyspaceName() {
    return environment.getProperty("cassandra.keyspace");
}

@Bean
public CassandraMappingContext cassandraMapping() throws ClassNotFoundException {
    return new BasicCassandraMappingContext();
}
}

UPDATE

I could able to create individual spring-data-cassandra and spring-data-neo4j modules seperately with other service modules and its working fine in both the modules. But I have another module with Neo4j spring-data-neo4j module in the same project, when I try to run both(neo4j+cassandra) the modules under the same project its creating the problem.

still waiting for the help! I have tried my best! Thanks!

0 Answers0