Dependency injection with Jersey 2.0

后端 未结 8 1117
遇见更好的自我
遇见更好的自我 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:17

    For me it works without the AbstractBinder if I include the following dependencies in my web application (running on Tomcat 8.5, Jersey 2.27):

    
        javax.ws.rs
        javax.ws.rs-api
        2.1
    
    
        org.glassfish.jersey.containers
        jersey-container-servlet
        ${jersey-version}
    
    
        org.glassfish.jersey.ext.cdi
        jersey-cdi1x
        ${jersey-version}
    
    
        org.glassfish.jersey.inject
        jersey-hk2
        ${jersey-version}
    
    

    It works with CDI 1.2 / CDI 2.0 for me (using Weld 2 / 3 respectively).

提交回复
热议问题