我是否需要在CDI bean中注入Conversation接口的getter? [英] Do I need getter for the injected Conversation interface in CDI bean?

查看:161
本文介绍了我是否需要在CDI bean中注入Conversation接口的getter?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 @ConversationScoped CDI bean,其中注入 Conversation 接口,并将访问修饰符设置为私有。这样的事情:

I have a @ConversationScoped CDI bean with a Conversation interface injected and access modifier set as private. Something like this:

@Named
@ConversationScoped
public class MySampleCdiBean implements Serializable {

    @Inject
    private Conversation conversation;

    //other stuffs
}

我的问题是做什么这个注入的会话界面需要一个getter吗? CDI容器需要这个吸气剂吗?我可以理解CDI容器如何处理对话的基本细节的任何资源也将非常有用。

My question is do I need a getter for this injected conversation interface? Does the CDI container need this getter? Any resource from where I can understand the underlying details of how CDI container handles a conversation would be super helpful too.

推荐答案

多种方法来定义注入类的注入点。到目前为止,您已注释引用注入对象的字段。您不需要为现场注入提供getter和setter。

There are multiple ways to define an injection point on the injected class. So far you have annotated the fields that reference the injected object. You do not need to provide getters and setters for field injection.

更多信息可以在这里找到:
https://netbeans.org/kb/docs/javaee/cdi-inject.html

More information can be found here: https://netbeans.org/kb/docs/javaee/cdi-inject.html

希望它有用。

这篇关于我是否需要在CDI bean中注入Conversation接口的getter?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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