Débora Débora - 10 months ago 99
Java Question

Jersey with Spring 4 Dependency Injection

I am to use Dependency Injection of Spring framework version 4. I have seen that the Jersey has its DI with plugin


Is Jersey's DI of Spring recommended or is there special reason to use it? What if Spring 4 DI is used independently ?

Also please let me know any step by step learning source to integration Spring DI with Jersey ?

Answer Source

The jersey-spring3 extension is not a stand-alone Dependency Injection feature, it's just an extension which makes Jersey aware of Spring's managed beans.

From Jersey - Spring DI:

Jersey provides an extension to support Spring DI. This enables Jersey to use Spring beans as JAX-RS components (e.g. resources and providers) and also allows Spring to inject into Jersey managed components.


The above module does not add any transitive dependency to Spring modules, so you will need to add Spring 3 dependencies explicitly into your dependency list.

So if you want to use Jersey with Spring you need jersey-spring3 and all the Spring dependencies you normally use.

By the way, the jersey-spring3 extension is compiled against Spring 3, but should work with Spring 4. See Using Jersey-spring with Spring 4.0 for reference.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download