i have a TimerTask class used to run scheduled jobs and when the job runs it executes some transactions on the database so i have a Dao as follows:
and the TimerTask:Code:@Repository @Transactional public class CampaignDaoImpl extends BasicDao implements CampaignDao { @Override public Campaign getCampaignListById(long id) throws DataAccessLayerException { return (Campaign) super.getById(Campaign.class, id); } }
the annotation scanner is set correctly, and the autowiring works fine in other classes in same packageCode:@Service("campaignSchedule") public class CampaignSchedule extends TimerTask { @Autowired private CampaignDao campaignDao; public synchronized void schedule() throws DException { log.debug("schedule >>> CampaignSchedule"); Campaign cam= campaignDao.getCampaignListById(1); } }
when debugging i found that campaignDao is null.Code:<context:component-scan base-package="com.mypackage" />
please advise how to fix this error.


Reply With Quote