Java의 라이브러리로 반복되는 메서드(기본 생성자부터 getter/setter 메서드 등..)를 Annotation 을 사용해서 자동으로 작성해주는 라이브러리다. Lombok 을 이용해서 작성한 코드는 컴파일 과정에서 Annotation 을 이용해서 코드를 생성하고 이런 결과물이 .class 에 담기게 된다.
<기존 필드 주입 방식>
@Service
public class UserService implements User {
@Autowired
private UserRepository userRepository;
}
<@RequiredArgsConstructor 방식>
@Service
@RequiredArgsConstructor
public class UserService implements User {
private final UserRepository userRepository;
}
@Override
@GetMapping("/test/{id}") // localhost:8080/test/1
public Header read(@PathVariable(name = "id") Long id) {
return null;
}
@Override
@GetMapping("/test/{id}", "/test") // localhost:8080/test/1, localhost:8080/test 둘다 가능
public Header read(@PathVariable(name = "id") Long id) {
return null;
}
*참고 자료
https://dpdpwl.tistory.com/140
https://sky-h-kim.tistory.com/16
https://velog.io/@kdhyo/JavaTransactional-Annotation-%EC%95%8C%EA%B3%A0-%EC%93%B0%EC%9E%90-26her30h
https://galid1.tistory.com/494