I know that there are a ton of questions regarding problems with Spring Autowired, but I could not find anything similar to mine, so sorry if its cheating ...
I am having problems creating an autwiring a bean (debugging shows that the constructor is running), but then it is not entered. No manual instance calls. I have many other auto-win fields in the project, and they work great. The funny thing, however, is that Ive used the same template and configuration in another project, and it works there ...
So here are the codes:
a bean that is created but not entered:
@Component("genericDao") public class GenericHibernateJpaDao implements GenericDao { @Autowired protected EntityManagerFactory entityManagerfactory; public GenericHibernateJpaDao() { }
The GenericDao interface defines only methods and has no annotations.
A service superclass defining a bean:
@Configurable public abstract class AbstractService { @Autowired protected GenericDao genericDao;
Service implementation (declaration bit):
@Service @Component public class WechatMessageService extends AbstractService implements IMessageService {
Breakpoint in service implementation in genericDao.saveOrUpdate(n); shows genericDao as null (this is also a string that returns NullPointerEx.) IMessageService -
@Service @Configurable @Transactional
application-config.xml (corresponding bits):
<beans .......... default-autowire="byName"> <context:component-scan base-package="package.with.dao" /> <context:component-scan base-package="package.with.service" /> <context:spring-configured/>
I guess this is just some pretty dumb mistake on my side, but I just can't figure it out, and googling doesn't help.
Thanks for any help.