Annotations are the new technology of DI. This started being used with Spring 2.5. There was no need for any XML files to maintain the configuration. To use the annotation-based configuration, you need to create a component class in which you can implement bean configurations. Annotations are unique names or markers on the pertinent class, function, or field revelation.
Presumably, you're familiar with @Override, which is an annotation that tells the compiler that this annotation is an abrogated function.
In the preceding annotations, the conduct of Spring Framework was to a great extent controlled through XML configuration. Today, the utilization of annotations gives us many advantages through the way we design the practices of Spring Framework.
Here's a piece of bean.xml code:
<?xml version = "1.0" encoding = "UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<context:annotation-config/>
<!-- bean definitions will be from here -->
</beans>
If we use <context:annotation-config/> in bean.xml, we can begin annotating the code to wire values into properties, functions, or constructors. We'll learn about a few essential annotations in the following sections.