faces-config.xml 中的注解与托管 bean 声明 [英] Annotations vs managed beans declarations in faces-config.xml

查看:25
本文介绍了faces-config.xml 中的注解与托管 bean 声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在接触 JSF 2.0,并且对新的基于注解的自动装配(在 faces-config.xml 中没有任何代码的托管 bean 的声明)有一定的疑问.

I'm getting my hands on JSF 2.0 and have certain doubt about new annotation based auto-wiring (declaration of managed beans without any code in faces-config.xml).

就我而言,注释很棒而且很容易,但问题可能在于在一个大系统中需要用另一个 bean 替换一个 bean,如果使用注释,将导致需要删除某些类(或类似的脏 hack),而它可以在 faces-cofig.xml 中轻松修复.

As far as I am annotations are great and easy, but problem may come to a certain need of substituting one bean with another in a big system which, if annotations were used, will result in a need to delete certain classes (or similar dirty hack), while it could be easily fixed in faces-cofig.xml.

请分享您对此事的经验.什么应该被认为更方便?为什么?

Please, share your experience on the matter. What should be considered more convenient and why?

推荐答案

正如 核心 JavaServer Faces(第三版):

在 JSF 2.0 之前,所有 bean 都必须使用 XML 进行配置.如今,你有注释和 XML 配置之间的选择.XML 配置相当详细,但如果您想在部署时配置 bean,它会很有用.

Before JSF 2.0, all beans had to be configured with XML. Nowadays, you have the choice between annotations and XML configuration. The XML configuration is rather verbose, but it can be useful if you want to configure beans at deployment time.

注解允许快速开发并减少冗余的 xml 编码.一般来说,这很大程度上取决于项目本身.

Annotations allow rapid development and reduce redundant xml coding. Generally, it greatly depends on the project itself.

这篇关于faces-config.xml 中的注解与托管 bean 声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆