-
카테고리
-
세부 분야
백엔드
-
해결 여부
미해결
@Service @Repository 해주는 이유
22.06.30 18:52 작성 조회수 514
0
안녕하세요. 강의 잘 듣고 있습니다. Service 코드와 Repository 코드 관련해서 의문이 하나 있는데요. ItemServiceV1이나 JdbcTemplateItemRepository, MyBatisItemRepository 등등에 @Service랑 @Repository를 해주는 이유는 뭔지 알 수 있을까요? (JdbcTemplate, MyBatis)Config에서 새로운 ItemService와 ItemRepository를 받아서 빈으로 만들어지 거면, @Service나 @Repository는 필요 없는 게 아닌지... 혹시 다른 이유가 있으신가요?
@SpringBootApplication(scanBasePackages = "hello.itemservice.web")
그리고 이 코드 때문에 @Service랑 @Repository를 붙여도 ComponentScan 대상에 제외되기 때문에 @Service랑 @Repository가 필요없을 거 같은데 아닌가영?
답변을 작성해보세요.
답변 2