HomeAboutMeBlogGuest
© 2025 Sejin Cha. All rights reserved.
Built with Next.js, deployed on Vercel
📝
남득윤 학습 저장소
/
🆚
VS 모음
/
@Controller, @Service, @Repository
@Controller, @Service, @Repository
@Controller, @Service, @Repository

@Controller, @Service, @Repository

@Controller 의 기능

  • @Controller 가 붙은 클래스는 컴포넌트 스캔의 대상이 된다.
  • @Controller 가 붙은 클래스는 Spring MVC의 핸들러로 등록된다.
 

@Service 의 기능 - 깡통

  • @Service 가 붙은 클래스는 컴포넌트 스캔의 대상이 된다.
 

@Repository 의 기능

  • @Repository 가 붙은 클래스는 컴포넌트 스캔의 대상이 된다.
  • @Repository 가 붙은 클래스는 예외 변환 AOP의 적용 대상이 된다.
    • 스프링과 JPA를 함께 사용하는 경우 스프링은 JPA 예외 변환기(PersistenceExceptionTranslator)를 등록한다.
    • 예외 변환 AOP 프록시는 JPA 관련 예외가 발생하면 JPA 예외 변환기를 통해 발생한 예외를 스프링 데이터 접근 예외로 변환한다.
    • PersistenceExceptionTranslationPostProcessor - @Repository를 AOP 프록시로 만드는 어드바이저 등록
    • notion image