java 何时调用标有@PostConstruct 的方法?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4061935/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 04:37:15  来源:igfitidea点击:

When method marked with @PostConstruct called?

javajsfannotationsjavabeans

提问by siva636

At which phase of the JSF request processing lifecycle, the backing bean method marked with @PostConstruct called?

在JSF请求处理生命周期的哪个阶段,@PostConstruct标记的backing bean方法被调用?

回答by Adeel Ansari

Methods marked with the @PostConstructwill be invoked after the bean has been created, dependencies have been injected, all managed properties are set, and before the bean is actually set into scope.

标记为 的方法@PostConstruct将在创建 bean、注入依赖项、设置所有托管属性之后以及在 bean 实际设置到作用域之前调用。

Found related SO thread, might not be exactly same but it answers your question. And a blog entryexplaining the same.

找到相关的 SO 线程,可能不完全相同,但它回答了您的问题。以及解释相同内容的博客条目