What does the @Component annotation?

4

What does Spring actually do when we put the @Component annotation in a class? How It Works "Beneath the Cloths"

    
asked by anonymous 08.03.2016 / 20:21

2 answers

3

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 .

    
09.03.2016 / 03:37
5

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

09.03.2016 / 07:19