[Spring] Annotation 정리


[Spring] Annotation 정리

@ComponentScan - @Component와 @Service, @Repository, @Controller, @Configuration이 붙은 클래스 Bean을 찾아서 Context에 bean 등록을 해준다. -@Component로 한 번에 처리할 수 있지만 각각에 맞게 쓰는 게 좋다. @AutoWired - field, settet, constructor에서 사용하며 Type에 따라 알아서 Bean을 주입 - 스프링이 자동적으로 값을 할당 - Controller 클래스에서 DAO나 Service에 관한 객체들을 주입 시킬 때 많이 사용 @Controller - Spring의 Controller를 의미한다. - API와 view를 동시에 사용하는 경우에 사용 - 대신 API 서비스로 사용하는 경우는 @ResponseBody를 사용하여 객체 반환 - view 리턴이 주목적 @RestController - Spri..........



원문링크 : [Spring] Annotation 정리