1

I have started using Jersey 2.27 to develop REST APIs. I could use Jersey-HK2 dependency to have dependency Injection working.

I tried to use Jersey-Guice as DI but it did not work. Is this supported off the shelf ? Has anyone made it work with version 2.27 ? For HK2 - the dependency is Jersey-HK2 , which has the version 2.27. Which is same as Jersey.

<dependency>
    <groupId>org.glassfish.jersey.inject</groupId>
    <artifactId>jersey-hk2</artifactId>
    <version>2.27</version>
</dependency>

But i did not find the jersey-guice of version 2.27. May be it is not supported as of yet in Jersey 2.27. Can anyone point me to any doc ?

Zooz
  • 11
  • 2
  • No, not unless you implement your own Guice InjectionManager. Jersey doesn't seem interested in doing this. You can follow [this issue](https://github.com/eclipse-ee4j/jersey/issues/3692). – Paul Samsotha Jun 29 '18 at 05:43
  • https://stackoverflow.com/questions/45620576/jersey-2-26-and-spring-4-3-10-but-no-hk2#comment78209510_45624308 – Paul Samsotha Jun 29 '18 at 05:46
  • Paul as always is right. Jersey now allows other DI providers to be implemented as an SPI. The issue with guice is that it works fundamentally differently than HK2 and CDI, so implementing the SPI with guice is difficult, and may be impossible without modifications to guice – jwells131313 Jun 29 '18 at 13:41

0 Answers0