gpt4 book ai didi

java - MyFaces - @PostConstruct 抽象类

转载 作者:行者123 更新时间:2023-11-30 09:40:19 27 4
gpt4 key购买 nike

我正在尝试执行抽象类中的 PostConstruct 注释方法,

    public abstract class AbstractTest {

@PostConstruct
public void init() {

}
}

@ManagedBean
@SessionScoped
public Test extends AbstractTest {

}

但是创建Test时没有调用init方法,是不是bug?不支持的功能?代码不正确?

在 Mojarra 2.1.6 上它可以工作

MyFaces 2.1.6,Glassfish 3.1.2-b23

最佳答案

Java EE section 5.2.3

Resource annotations may appear on any of the classes listed above, or on any superclass of any class listed above. A resource annotation on any class in the inheritance hierarchy defines a resource needed by the application component.

对我来说听起来像是个错误!显然 Mojarra 在某个时间点有相同的错误并且已修复:issue 800 .

关于java - MyFaces - @PostConstruct 抽象类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9472605/

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