is it mandatory to write a setter function when we use @Inject annotation
Asked
Active
Viewed 159 times
-2
-
the documentation of that annotation explains what it can do: https://docs.oracle.com/javaee/7/api/javax/inject/Inject.html – zapl Oct 13 '22 at 20:36
2 Answers
0
No, we don,t have to write the setter method for @Inject, it is same annotation as the @Autowired.
@Inject is part of a Java technology called CDI that defines a standard for dependency injection similar to Spring. In a Spring application, the two annotations works the same way as Spring has decided to support some JSR-299 annotations in addition to their own.
@Inject can be injected the reference to the implementation of the Provider interface, which allows injecting the deferred references.

Sandeep Kumar Nat
- 470
- 1
- 7