What does Spring actually do when we put the @Component
annotation in a class? How It Works "Beneath the Cloths"
What does Spring actually do when we put the @Component
annotation in a class? How It Works "Beneath the Cloths"
According to definition of creators , it represents a component ( bean
) that is detected automatically when working with annotation based configurations and classpath search.
Other elements, such as @Repository
, @Service
and @Controller
, are some stereotypes that implement @Component
. This way, you can create another specialization of @Component
according to your need.
Example:
@Component
@Scope("prototype")
public @interface MinhaClasse{
...
}
In this way, we have a new specialization of @Component
.
Spring supports the @Component
annotation since its version 2.5 , and is intended to indicate to the framework that that class is a bean that should be administered by