
Lombok 라이브러리 사용

build.gradle의 dependencies에 Lombok Gradle을 붙여넣는다.


인스톨까지 하면 Lombok 사용할 수 있다. *Lombok은 반드시! 라이브러리 추가와 함께 Plugins도 해줘야 사용할 수 있다. (Lombok은 어노테이션을 사용하게 만들어주는 라이브러리이기 때문!)
어노테이션 (Annotation) = JVM의 주석
JVM이 실행시에 참조해서 보는 주석. 즉, JVM의 주석! (//같은건 인간이 보는 주석이라 JVM이 무시함)

GETTER를 @Getter로 어노테이션 시켰다. 그러면 실행을 했을 때, JVM이 …GETTER네? 하고. @Getter를 보고 힌트를 가져가서 **GETTER 를 실행 시에!!! 만들어줌. 실행시에!! GETTER를 만든다!!!!** 즉, 이 GETTER는 코드상에선 존재하지 않는다. .java에는 없고, 컴파일하는 .class파일에 getter를 쫙 만드는 것 실행 전엔 GETTER가 없고, 실행 후엔 GETTER가 생기는 것…
따라서, 인텔리j 툴 자체에서는 GETTER가 없는걸로 인식해서 오류가 남!! -> Plugins 설치 필요!! (그래서 Plugins에서 Lombok을 또 깔아줌) GETTER를 실행시에 쫙 만드는건 Lombok 라이브러리지만, 인텔리j에서 Lombok을 인식시키기 위해 깐게 Plugins - Lombok이다.
Annotation 사용법

@Data 하면 GETTER, SETTER, toString까지 모두 만들어줌

생성자도 이렇게!!! AllArgsConstructor 하면 풀 생성자를 만들어줌!!!!

NoArgsConstructor 하면 기본 생성자를 만들어줌!!!!!!

Share article