Terminology
Learn about the different terms used in the world of Spring.
We'll cover the following
Beans
Beans are the objects of classes that are managed by Spring. Traditionally, objects used to create their own dependencies, but Spring manages all the dependencies of an object and instantiates the object after injecting the required dependencies. The @Component
annotation is the most common method of defining beans.
@Component
public class Vehicle {
//...
}
Autowiring
The process of identifying a dependency, looking for a match, and then populating the dependency is called autowiring. The @Autowired
annotation tells Spring to find and inject a collaborating bean into another. If more than one bean of the same type is available, Spring throws an error. In the following scenario, two beans of type Operator
are detected by Spring: