@Inject and @Autowired

@Inject is part of the Java CDI standard introduced in Java EE 6 (JSR-299), read more. Spring has choosen to support using@Inject synonymously with their own @Autowired annotation.

So, to answer your question, @Autowired is springs own (legacy) annotation. @Inject is part of a new 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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s