@Component
--이 클래스가 컴포넌트로서 컨테이너에 등록
@Data
-- lombok 에서 제공하는 라이브러리
-- setter , getter 와 같은 기본 메서드들을 등록해 준다.
@Setter(onMethod_= 어노테이션)
사용 예시
Chef 클래스
1
2
3
4
5
|
@Component
@Data
public class Chef{
}
|
cs |
Restaurant 클래스
1
2
3
4
5
6
7
8
9
10
|
@Component
@Data
public class Restaurant {
//컴파일 시 자동으로 setChef() 메소드를 생성한다.
//Chef 클래스의 setChef() 는 @Data가 만들어 준다.
//onMethod_ 는 생성된 setChef() 메소드에 @Autowired 를 추가해준다.
@Setter(onMethod_ = @Autowired)
private Chef chef;
}
|
cs |
DTO에서
@DateTimeFormat(pattern = "yyyy/mm/dd")
메소드
예외처리에서
@ResponseStatus(HttpStatus.NOT_FOUND)
--responseStatus가 not found 일때
lombok에서
@AllArgsConstructor
--모든 필드값을 파라미터로 받는 생성자를 만들어 준다.