Annotation-based DI
From the beginning, the most common way of defining configuration in Spring has been XML-based. But when the complexity grew and navigation of beans became exhausted in the jungle of angle brackets, there was a demand for a second option to define configuration. As a result, Spring started support for annotation.
Annotation-based configuration is an alternate of XML-based configuration, and it relies on bytecode metadata. Spring started support for annotation with version 2.5. With annotation, the configuration moves from an XML to component class. Annotation can be declared on classes, methods, or at field level.
Let's understand the process of defining configuration through annotation. We will first understand this process ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access