简体   繁体   English

通过提供setter和getter的EJB SessionContext @Resource属性注入

[英]EJB SessionContext @Resource property injection by providing setter and getter

I have an EJB class which is having 我有一个EJB类

@Resource
private SessionContext objSessionContext;

will injection works fine if i provide setter and getter for this property. 如果我为此属性提供二传手和吸气剂,将注射工作正常。

It will work as before, only location of @Resource annotation matters. 它将像以前一样工作,仅@Resource批注的位置很重要。

Eventually injection can also be moved to set method, if preferred: 最终,如果需要的话,也可以将注入移动到set方法中:

@Resource
private void setObjSessionContext(SessionContext obj) {
    objSessionContext = obj;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM