Spring+TestNG: packages not scanned for annotations
-
29-04-2021 - |
Question
I have a simple (ant based) test based on AbstractTransactionalTestNGSpringContextTests
. I get an error complaining no suitable bean found for auto wiring.
@Autowired
@Qualifier("userSessionDao")
private UserSessionDAO userSessionDao;
The DAO:
@Repository("userSessionDao")
public class UserSessionDAOImpl extends
AbstractGenericDAOImpl<UserSession, Long> implements UserSessionDAO {
/**
*
*/
@SuppressWarnings("unused")
private XLogger logger = XLoggerFactory.getXLogger(UserSessionDAOImpl.class
.getName());
}
I have the following in the config.xml: < context:component-scan base-package="com.blah" />
Am I missing a step to make component-scan kick in?
Solution
Try <context:component-scan base-package="com.blah.*" />
Also, check that UserSessionDAO
is an autowired candidate.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow