In last Spring auto-wiring in XML example, it will autowired the matched property of any bean in current Spring container. In most cases, you may need autowired property in a particular bean only.
In Spring, you can use @Autowired annotation to auto wire bean on the setter method, constructor or a field. Moreover, it can autowired property in a particular bean.
The @Autowired annotation is auto wire the bean by matching data type.
See following full example to demonstrate the use of @Autowired.

1. Beans

A customer bean, and declared in bean configuration file. Later, you will use “@Autowired” to auto wire a person bean.
package com.mkyong.common;
public class Customer 
 //you want autowired this field.
 private Person person;
 private int type;
 private String action;
 //getter and setter method
  id="CustomerBean" class="com.mkyong.common.Customer">
   name="action" value="buy" />
   name="type" value="1" />