【发布时间】:2021-06-26 15:27:44
【问题描述】:
我的服务是:
@Singleton
@TransactionManagement(TransactionManagementType.BEAN)
public class JobTest {
@Resource
private TimerService timerService;
@PostConstruct
public void init() {
timerService.createTimer(0,1000, "Every second timer with no delay");
}
@Timeout
public void execute() {
System.out.println("execute your job here");
}
}
但是,作业没有执行。但是当将@Startup 添加到服务时,代码会按预期运行。你能解释一下为什么我们需要@Startup 来使用 timerService 资源吗?
【问题讨论】:
标签: timer ejb scheduling java-ee-8