Pass Parameter to Instance of @Inject Bean

后端 未结 2 523
天涯浪人
天涯浪人 2020-12-30 06:38

I am using CDI as injection framework, but I have found some limitations in its usage, and this is one of them. I am trying to initialize the creation of a bean instance wit

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-30 07:25

    According to the specification, there is no way to have a bean with a not simple, "not injecting" constructor ( 3.1. Managed beans , 3.9. Bean constructors ).

    Therefore, the ways to set the parameters are to have the setMethod() for them, make them as @Inject fields in the bean or annotate the constructor with the annotation @Inject and make the parameters of the constructor to be injectable ( 5.5.1. Injection using the bean constructor )

    I hope, I answered the question.

提交回复
热议问题