Dependency injection with Jersey 2.0

后端 未结 8 1110
遇见更好的自我
遇见更好的自我 2020-11-22 01:18

Starting from scratch without any previous Jersey 1.x knowledge, I\'m having a hard time understanding how to setup dependency injection in my Jersey 2.0 project.

相关标签:
8条回答
  • 2020-11-22 02:18

    If you prefer to use Guice and you don't want to declare all the bindings, you can also try this adapter:

    guice-bridge-jit-injector

    0 讨论(0)
  • 2020-11-22 02:19

    Late but I hope this helps someone.

    I have my JAX RS defined like this:

    @Path("/examplepath")
    @RequestScoped //this make the diference
    public class ExampleResource {
    

    Then, in my code finally I can inject:

    @Inject
    SomeManagedBean bean;
    

    In my case, the SomeManagedBean is an ApplicationScoped bean.

    Hope this helps to anyone.

    0 讨论(0)
提交回复
热议问题