adspace


Explain the difference between @autowired and @inject?

Answer Posted / Ravinder Rawat

"@Autowired" is a Spring Framework annotation used for Dependency Injection in Java. It automatically injects the dependency based on the type matching between the field, method parameter, or constructor argument, with a bean in the Spring ApplicationContext.nnOn the other hand, "@Inject" is a generic Dependency Injection annotation that can be used in various Java frameworks including CDI (Contexts and Dependency Injection for the Java EE platform) and Google Guice. Spring Framework also supports @Inject but it's not as widely used as @Autowired because of its more verbose syntax and lesser integration with Spring."

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is lazy class?

490


How can you inject java collection in spring?

518


What is difference between @controller and @restcontroller in spring?

556