我的 dropwizard 项目中有这个日晷任务:
@SimpleTrigger(repeatInterval = 10, timeUnit = TimeUnit.SECONDS)
public class GitlabImporter extends Job {
private static BranchDAO branchDAO;
@Override
@ExceptionMetered
public void doRun() throws JobInterruptException {
branchDAO = (BranchDAO) SundialJobScheduler.getServletContext().getAttribute("BranchDAO");
String jobId = UUID.randomUUID().toString();
try {
...
log.info(branches.toString());
} catch (Exception e) {
log.error(e.getLocalizedMessage());
}
}
}
我尝试在 Sceduler 任务中使用我的 DAO,我想按照日晷文档如何加载对象,但它似乎不起作用。在我的日晷任务中使用休眠项目的正确方法是什么?
谢谢