Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between javax.inject.Inject and com.google.inject.Inject?

Tags:

I'm initiating myself to Google Guice.

I have a simple question :

What is the difference between the javax.inject's @Inject annotation and the com.google.inject's @Inject one ?

Thanks.

like image 796
Maoori Avatar asked Jan 06 '12 10:01

Maoori


People also ask

What is javax inject inject?

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).

What does Google @inject do?

@Inject annotates constructors and methods that determine what an object needs to be initialized. There are also a lot of other annotations that determine how Guice works. But simply annotating objects isn't enough; you also have to configure them with Guice bindings.

What is the difference between @inject and @autowired?

@Inject and @Autowired both annotations are used for autowiring in your application. @Inject annotation is part of Java CDI which was introduced in Java 6, whereas @Autowire annotation is part of spring framework. Both annotations fulfill same purpose therefore, anything of these we can use in our application. Sr.

What is the difference between @inject and @autowired in Spring?

The behaviour of the @Autowired annotation is similar to the @Inject annotation. The only difference is that the @Autowired annotation is part of the Spring framework. This annotation has the same execution paths as the @Inject annotation, listed in order of precedence: Match by Type.


1 Answers

javax.inject is a specification derived from google's work (and others)

Difference can be found in Google Guice Wiki

like image 85
Grooveek Avatar answered Sep 28 '22 10:09

Grooveek