hrming

[Spring] @Component 본문

Spring

[Spring] @Component

hrming 2024. 3. 4. 01:46

@Component

@Component is an annotation that allows Spring to detect our custom beans automatically.

In other words, without having to write any explicit code, Spring will:

  • Scan our application for classes annotated with @Component
  • Instantiate them and inject any specified dependencies into them
  • Inject them wherever needed

However, most developers prefer to use more specialized stereotype annotations to serve this function.

→ Spring has provided a few specialized stereotype annotations: @Controller, @Service and @Repository.

They all provide the same function as @Component.

 

They all act the same because they are all composed annotations with @Component as a meta-annotation for each of them. 

 


출처: https://www.baeldung.com/spring-component-annotation

 

'Spring' 카테고리의 다른 글

[Spring] Spring Security  (0) 2024.03.14
[Spring] Validation & BindingResult  (1) 2024.03.08
VO(Value Object)  (0) 2022.08.18
Spring DI  (0) 2022.05.31
AOP(Aspect Oriented Programming)  (1) 2022.05.30
Comments