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?
Package javax. inject. This package specifies a means for obtaining objects in such a way as to maximize reusability, testability and maintainability compared to traditional approaches such as constructors, factories, and service locators (e.g., JNDI).
Use of Google Guice for implementing dependency injection in application is very easy and it does it beautifully. It's used in Google APIs so we can assume that it's highly tested and reliable code.
Interface Injector. public interface Injector. Builds the graphs of objects that make up your application. The injector tracks the dependencies for each type and uses bindings to inject them. This is the core of Guice, although you rarely interact with it directly.
Package com. google. inject Description. Google Guice (pronounced "juice") is an ultra-lightweight dependency injection framework.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With