Hello,
I'm a total beginner to spring and IoC, and i got some difficulties to setup a Spring webapp.
I'm actually trying to implement a mongodb DAO, and inject it in a service layer trough annotation.
My DAO bean is not found by spring.
Here's some part of my code :
IUserDao.java
UserDaoMongo.javaCode:public interface IUserDao { //A Simple Interface, nothing special }
IUserService.javaCode:@Repository("UserDao") public class UserDaoMongo implements IUserDao { //My own implementation of the DAO }
UserServiceImpl.javaCode:public interface IUserService { //Here again, a simple interface, nothing special }
context-mongo.xmlCode:@Service("UserService") public class UserServiceImpl implements IUserService, UserDetailsService { @Autowired(required=true) @Qualifier("UserDao") private IUserDao userDao; //This one is the funny part. My UserService implement UserDetailsService, to be used with spring security. //I Thought it was the good place to that. }
And i got the following error :Code:<?xml version="1.0" encoding="UTF-8"?> <beans:beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:mongo="http://www.springframework.org/schema/data/mongo" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo-1.1.xsd"> <mongo:mongo host="${mongo.address}" port="${mongo.port}" /> <beans:bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate"> <beans:constructor-arg ref="mongo" /> <beans:constructor-arg name="databaseName" value="${mongo.database}" /> </beans:bean> <context:annotation-config /> </beans:beans>
I already tried to add "<repositories base-package="" />" without success.Code:org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [my.package.dao.IUserDao] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true), @org.springframework.beans.factory.annotation.Qualifier(value=UserDao)}
I tryed to googling my problem, but all solutions found wasn't really helpful. Or may i wasn't able to totally understand my mistake and wasn't able to know what to search exactly.
Also i don't know how to investigate further to understand this problem. I'm not only a beginer to Spring, but also to Java.
Thanks for any help.


Reply With Quote