gpt4 book ai didi

Java EE 7 自动计时器(EJB 计时器)不适用于 WildFly 8.1.0

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:58:49 26 4
gpt4 key购买 nike

我正在关注 Using the Timer Service构建简单计划执行的教程。尝试自动方法并使用 WildFly 8.1.0 Final

session Bean

@Singleton
@Startup
public class HelloJob {

private static final Logger logger = Logger.getLogger(HelloJob.class);

public HelloJob() {
logger.error(">>> Hello Job Created.");
}

@Schedule(second="*")
public void sayHello() {
logger.error(">>> Server Hello!");
}

}

在部署时,类被正确实例化并打印 >>> Hello Job Created. 消息,但方法 sayHello() 从未被调用。

根据教程,@Schedule(second="*") 意味着它应该每秒执行一次。

Setting an attribute to an asterisk symbol (*) represents all allowable values for the attribute.

定时器也只允许有状态 session bean,我使用的是单例,示例中也使用了单例。

The timer service of the enterprise bean container enables you to schedule timed notifications for all types of enterprise beans except for stateful session beans.

最佳答案

使用 @Schedule(second="*", minute="*", hour="*")

小时和分钟的默认值是“0”,这可能会很烦人并有效地迫使您设置它们。

关于Java EE 7 自动计时器(EJB 计时器)不适用于 WildFly 8.1.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24194638/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com