본문 바로가기
스터디IT🌼/SpringBoot

[SpringBoot] Lombok Annotation Processer 에러 ( Cannot find Symbol )

by 동백사과 2022. 1. 14.

Lombok

Lombok은 간단하게 BEAN(POJO)를 작성할 수 있도록 도와주는 라이브러리입니다.
Annotation을 이용해 데이터 클래스를 작성하며 발생하는 보일러플레이트를 줄여줍니다.

 

에러 내용!

Annotation processors must be explicitly declared now.  The following dependencies on the compile classpath are found to contain annotation processor.  Please add them to the annotationProcessor configuration.
  - lombok-1.12.4.jar (org.projectlombok:lombok:1.12.4)
Alternatively, set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true to continue with previous behavior.  Note that this option is deprecated and will be removed in the future.
See https://developer.android.com/r/tools/annotation-processor-error-message.html for more details.

- lombook annotationprocessor가 설치되어있지 않다는 오류..!

 

또는 

- lombok @Getter를 설정했음에도 불구하고 컴파일에서 cannot find error가 발생했다. 

 

 

해결 방법!

1. build.gradle에서 lombok & lombok AnnotationProcesser 명시

compileOnly "org.projectlombok:lombok:1.16.20"
annotationProcessor "org.projectlombok:lombok:1.16.20"

또는

implementation 'org.projectlombok:lombok:1.18.16'
annotationProcessor 'org.projectlombok:lombok'

- 위 코드를 build.gradle에 넣어주고 build.gradle를 Reload한다! ( lombok 버전 명시는 꼭 해주자!)

 

 

2. Lombok 설치

- 당연히 lombok이 설치되어있어야한다! File->Settings->Plugins->Marketplace에서 lombok을 검색한 뒤 설치해준다.! 설치되면 위 사진과 같이 installed에 lombok이 있는 것을 볼 수 있다. 

 

3. Enable annotation processing

- File ->Settings->Build -> Compiler -> Annotation Processors 에  Enable anotation processing 체크박스를 체크한다!

 

 

4. Compile을 Eclipse로 바꾸고 VM 설정에 "-javaagent:lombok" 설치 path 입력하기

[참고링크]

https://stackoverflow.com/questions/24006937/lombok-annotations-do-not-compile-under-intellij-idea/30125507#30125507

 

Lombok annotations do not compile under Intellij idea

I've installed the plugin for intellij idea(lombok-plugin-0.8.6-13). Added lombok.jar into classpath I can find getters and setters in the window of structure. And Intellij shows no error. Setting -

stackoverflow.com

- 사실 나의 경우 위 1~3방법으로 해결되긴 했지만 비슷한 문제를 겪은 사람들이 이 방법도 사용했다해서 같이 글을 남겨놓는다! 1~3번 방법으로 해결 되지 않았을 시 참고해보면 좋을 거 같다.

 


[ 참고 문헌 ]

- https://stackoverflow.com/questions/65128763/java-you-arent-using-a-compiler-supported-by-lombok-so-lombok-will-not-work-a
- https://github.com/projectlombok/lombok/issues/1503

- https://ifuwanna.tistory.com/292

댓글