Auto-wiring in Spring

So far, we have learned how to define configuration metadata along with <bean> to set the dependencies. How good would it be if everything was settled down without giving any instruction in the form of configuration? That is a cool idea, and the good news is that Spring supports it.

This feature is called autowire (in Spring terminology), which automates the process of binding relations between beans. This greatly reduces the effort of providing configuration metadata at either properties or constructor arguments.

The autowire feature can be enabled in XML-based configuration metadata by defining the autowire attribute of the <bean> element. It can be specified with the following three modes: name, type, and constructor. ...

Get Java 9 Dependency Injection now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.