Replacing com.google.inject with javax.inject

Blessed Geek picture Blessed Geek · Oct 20, 2011 · Viewed 16.7k times · Source

Is it true that javax.inject annotations can function as direct replacements for com.google.inject?

So that, if I replaced all my current guice/gin annotations with those from javax.inject, my app would compile and run just fine?

First, does javax.inject cover all the bases that google.inject cover?

Answer

Bozho picture Bozho · Oct 20, 2011

Yes, it will work fine. In fact the author of guice (Bob Lee) is a spec-lead for the javax.inject specification.

javax.inject.Inject does not have the optional attribute, so if you want an optional dependency, you'd have to use the guice annotation.