참고 : http://namocom.tistory.com/421
1.10.1. @Component
and Further Stereotype Annotations
The @Repository
annotation is a marker for any class that fulfills the role or stereotype of a repository (also known as Data Access Object or DAO). Among the uses of this marker is the automatic translation of exceptions, as described in Exception Translation.
Spring provides further stereotype annotations: @Component
, @Service
, and @Controller
. @Component
is a generic stereotype for any Spring-managed component. @Repository
, @Service
, and @Controller
are specializations of @Component
for more specific use cases (in the persistence, service, and presentation layers, respectively). Therefore, you can annotate your component classes with @Component
, but, by annotating them with @Repository
, @Service
, or @Controller
instead, your classes are more properly suited for processing by tools or associating with aspects. For example, these stereotype annotations make ideal targets for pointcuts. @Repository
, @Service
, and @Controller
can also carry additional semantics in future releases of the Spring Framework. Thus, if you are choosing between using @Component
or @Service
for your service layer, @Service
is clearly the better choice. Similarly, as stated earlier, @Repository
is already supported as a marker for automatic exception translation in your persistence layer.
어노테이션 | 유스케이스 |
@Repository | 퍼시스턴스(persistence) 레이어, 영속성을 가지는 속성(파일, 데이터베이스 등) |
@Service | 서비스 레이어 |
@Controller | 프레젠테이션 레이어 |
component 의 구체화 -> Service
https://okky.kr/article/367591
WEB(사용자) ==요청==> Controller ==요청==> Service (내부적인 처리) ==리턴값==> Controller
'Develope > Programming' 카테고리의 다른 글
[encoding] utf-8 이 안먹힐 때 (0) | 2018.12.04 |
---|---|
[Python] SqlLite를 이용한 Create Table 및 Pandas 출력 (1) | 2018.11.06 |
[JAVA] Exception 출력 정리 (0) | 2018.10.15 |
[Telegraf] Exec plugin test (0) | 2018.06.12 |
[Jolokia + Telegraf] Agent Mode, Proxy Mode 실행방법 및 테스트 (0) | 2018.06.12 |