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 through XML configuration, and then will gradually move to annotation-based configuration in the following sections.
...