Author | Message |
---|---|
ajoshi5
Posts: 7
|
Posted 20:11 Feb 01, 2016 |
Hello , ... ... .... ..... ..... Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: gapp.web.model.dao.UserDao gapp.model.dao.UserDaoTest.userDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [gapp.web.model.dao.UserDao] 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)} FAILED CONFIGURATION: @BeforeClass springTestContextPrepareTestInstance
... ... ...
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: gapp.web.model.dao.UserDao gapp.model.dao.UserDaoTest.userDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [gapp.web.model.dao.UserDao] 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)} SKIPPED CONFIGURATION: @BeforeMethod springTestContextBeforeTestMethod ===============================================
|
ajoshi6
Posts: 46
|
Posted 20:14 Feb 01, 2016 |
it seems that Spring can't find bean to be injected. check if that related bean is present or not. @Autowired exception it is |
ajoshi5
Posts: 7
|
Posted 20:16 Feb 01, 2016 |
yea of course have seen @Autowired exception in the given error para, and looked for the solution on google as well but every dependency has been checked and is exist even tho it keeps coming . |
SavinSachdev
Posts: 3
|
Posted 21:05 Feb 01, 2016 |
I think u r forgetting @Repository annotation in the Dao implementation classes
|
ajoshi5
Posts: 7
|
Posted 21:07 Feb 01, 2016 |
@SAVIN , Thanks for your reply .I Got the same solution on stackoverflow :) and double checked all dao-s and daoimpl-s but all those annotations (specially @repository) are OK . :/ |
anto004
Posts: 4
|
Posted 21:38 Feb 01, 2016 |
Try adding a base-package in your applicationContext.xml eg: <context:component-scan base-package="hw3.model" />
Last edited by anto004 at
21:39 Feb 01, 2016.
|
ajoshi5
Posts: 7
|
Posted 21:41 Feb 01, 2016 |
@ANT , thanks as well . <context:annotation-config /> <tx:annotation-driven /> <context:component-scan base-package="modelname" /> |
cysun
Posts: 2935
|
Posted 21:53 Feb 01, 2016 |
Assuming everything else is correct, it may be because you have two <component-scan> (one in gapp-servlet.xml and one in applicationContext.xml) that scan overlapping packages. Move your model package out of gapp.web to gapp.model. The <component-scan> in gapp-servlet.xml should scan gapp.web and the one in applicationContext.xml should scan gapp.model. |
ajoshi5
Posts: 7
|
Posted 07:00 Feb 02, 2016 |
Thank You professor . You are right about two <component-scan> But I have already checked it on the same time and both XML-s are scanning two different models as shown in attachments . |
cysun
Posts: 2935
|
Posted 11:30 Feb 02, 2016 |
The error message says "Could not autowire field: gapp.web.model.dao.UserDao gapp.model.dao.UserDaoTest.userDao ..." which shows that your UserDao is under the web package. The test cases only uses applicationContext.xml, i.e. the <component-scan> in gapp-servlet.xml is not run so the bean was not created. Move it to gapp.model should fix the problem. |