O'Reilly logo

Hands-On High Performance with Spring 5 by Dinesh Radadiya, Prashant Goswami, Pritesh Shah, Subhash Shah, Chintan Mehta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The @Autowired annotation

The @Autowired annotation injects object dependency implicitly. We can use the @Autowired annotation on a constructor-setter-and field-based dependency pattern. The @Autowired annotation indicates that auto wiring should be performed for this bean.

Let's look at an example of using the @Autowired annotation on a constructor-based dependency:

public class BankingService {    private CustomerService customerService;    @Autowired  public BankingService(CustomerService customerService) {    this.customerService = customerService;  }  ......}

In the previous example, we have BankingService that has a dependency of CustomerService. Its constructor is annotated with @Autowired, indicating that Spring instantiates the BankingService ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required