java - Little trouble with hibernate autowire in a spring project, bean not found error -


i wanted try <context:component-scan base-package /> feature of spring 3.0.5.

i have entry in applicationcontext :

<context:component-scan base-package="com.project.personal.admin.model"/> <context:annotation-config /> 

i have manager class knows how create pojo , dao.

@component("manager") public class managerimpl implements applicationcontextaware, manager {    applicationcontext applicationcontext;    public void setapplicationcontext(applicationcontext applicationcontext) throws beansexception {     this.applicationcontext = applicationcontext;   }    public user createuser(){     return (user) getinstance("user", user.class);   }     public userdao createuserdao(){     return (userdao) getinstance("userdao", userdao.class);   }  //.... } 

a pojo :

@entity @table(name = "user", uniqueconstraints = { @uniqueconstraint(columnnames = {"email"})}) @component("user") public class user {    public user() {     this.datecreated = new date();   }     @id   @generatedvalue(generator = "uuid")   @genericgenerator(name = "uuid", strategy = "uuid.hex")   @column(name = "id", length = 32)   private string id;   @column(name = "email", length = 150)   private string email;   //setters , getters } 

my test class

@runwith(springjunit4classrunner.class) @contextconfiguration(locations={"classpath:meta-inf/test-project-admin-config.xml"}) @transactionconfiguration(defaultrollback=true) @transactional public class userdaoimpltest {     //@autowired     @resource(name="manager")     manager manager;      @autowired     userdao userdao;      public userdaoimpltest() {     }      @test     public void testsave() {         user u1 = manager.createuser();         u1.setemail("misterjojtoo@gmail.com");         u1.setfullname("joseph djomeda");         u1.setpassword("psaumedetdavid");         userdao.save(u1);         user expresult = u1;          user result = (user)userdao.getbyid(u1.getid());          assert.assertequals(expresult, result);         assert.assertequals(expresult.getid(), result.getid());      }      } 

i'm having error :

org.springframework.beans.factory.nosuchbeandefinitionexception: no matching bean of type [com.project.personal.admin.manager.manager] found dependency: expected @ least 1 bean qualifies autowire candidate dependency. dependency annotations: {@org.springframework.beans.factory.annotation.autowired(required=true)}

most of time create entry in applicationcontext each class, , it's been working, time along wanted try package scanning. i'm not doing well? i've tried autowired , later resource. i'm out of ideas

thanks reading this.

make sure manager in right package (or base-package set properly) (i wouldn't mention this, seems suspicious have manager in model package)


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -