Do I need getter for the injected Conversation interface in CDI bean?

萝らか妹 提交于 2019-12-11 10:45:37

问题


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
}

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.


回答1:


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.

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

hope its helpful.



来源:https://stackoverflow.com/questions/33383446/do-i-need-getter-for-the-injected-conversation-interface-in-cdi-bean

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!