Intellij 아이디어에서 롬복 주석이 컴파일되지 않음
이 질문에는 이미 답변이 있습니다.
- intellij idea (lombok-plugin-0.8.6-13) 용 플러그인을 설치했습니다.
- 클래스 경로에 lombok.jar 추가
- 구조 창에서 게터와 세터를 찾을 수 있습니다. 그리고 Intellij는 오류가 없습니다.
- 설정-Lombok 플러그인-lombok에 대한 확인 된 Intellij 구성, "IntelliJ 구성이 정상인 것 같습니다"라는 메시지가 표시됩니다.
모든 것이 정상인 것 같습니다. 그러나 테스트를 컴파일 할 때 오류가 발생합니다 : getXXX 및 setXXX 메소드를 찾을 수 없습니다.
IntelliJ로 .class 파일을 열고 setXXX 및 getXXX 메소드가 없다는 것을 알았습니다.
누군가 왜 그런지 말해 줄래?
- 플러그인 : lombok-plugin-0.8.6-13
- lombok.jar : 1.14.0
- 아이디어 : 리눅스의 경우 13.0.2
- jdk : 1.7.0_21
문제 세트를 해결하려면 다음을 수행하십시오.
- 환경 설정 ( Ctrl+ Alt+ S)
- 빌드, 실행, 배포
- 컴파일러
- 주석 처리기
- 주석 처리 사용
- 주석 처리기
- 컴파일러
- 빌드, 실행, 배포
IntelliJ 용 Lombok 플러그인이 설치되어 있는지 확인하십시오!
- 환경 설정
->플러그인 - "롬복 플러그인"검색
- 저장소 찾아보기 ...를 클릭하십시오.
- 롬복 플러그인 선택
- 설치
- IntelliJ를 다시 시작하십시오.
lombok과 함께 Eclipse 컴파일러를 사용하는 경우이 설정은 마침내 저에게 효과적이었습니다.
- 아이디어 14.1
- 롬복 플러그인
- ... / 컴파일러 / Java 컴파일러 > 컴파일러 사용 : Eclipse
- ... / 컴파일러 / 주석 프로세서 > 주석 처리 사용 : 선택 (기본 구성)
- ... / 컴파일러 > 추가 빌드 프로세스 VM 옵션 : -javaagent : lombok.jar
가장 중요한 부분은 마지막 부분이며 내 모습은 다음과 같습니다. 
플러그인은 IntelliJ 편집기가 게터 및 세터를 인식하는 데 필요하며 javaagent는 이클립스 컴파일러가 롬복으로 컴파일하는 데 필요합니다.
Mac에서 Intellij를 사용하는 경우이 설정이 마침내 효과가있었습니다.
설치 : Intellij
- 환경 설정으로 이동하여 플러그인을 검색하십시오.
- 플러그인 검색 창에 "Lombok"을 입력하십시오. 롬복은 번들로 제공되지 않는 플러그인이므로 처음에는 표시되지 않습니다.
- 번들로 제공되지 않는 플러그인을 검색하려면 "찾아보기"를 클릭하십시오.
- "롬보 플러그인"이 나타납니다. 그것을 선택하십시오.
- 녹색 "설치"버튼을 클릭하십시오.
- "Intellij IDEA 다시 시작"버튼을 클릭하십시오.
설정 :
주석 프로세서 사용
- 환경 설정-> 빌드, 실행, 배치-> 환경 설정-> 컴파일러-> 주석 프로세서로 이동하십시오.
- 파일-> 기타 설정-> 기본 설정-> 컴파일러-> 주석 프로세서
Lombok 플러그인이 활성화되어 있는지 확인
- IntelliJ IDEA-> 환경 설정-> 기타 설정-> 롬복 플러그인-> 롬복 사용
글로벌 라이브러리 및 프로젝트 종속성에 Lombok jar을 추가하십시오.
- 파일-> 프로젝트 구조-> 글로벌 라이브러리 (lombok.jar 추가)
파일-> 프로젝트 구조-> 프로젝트 설정-> 모듈-> 종속성 탭 = 롬복 확인
Intellij를 다시 시작하십시오.
저에게는 롬복 플러그인과 주석 처리가 모두 필요합니다. Eclipse 및 추가 -javaagent : lombok.jar 옵션 을 사용할 필요가 없습니다 .
- 아이디어 14.1.3, 빌드 141.1010
- Lombok plugin[Preference->plugins->browse repositories->search 'lombok'->install and restart idea.
- Preference ->search 'annotation'->enter annotation processor ->enable annotation processing.
IDEA 2016.1:
- Install lombok plugin
- Settings -> Compiler -> Annotation Processors -> Enable annotation processing: checked (default configuration)
- Settings -> Compiler -> Annotation Processors -> Annotation Processors add "lombok.launch.AnnotationProcessorHider$AnnotationProcessor"
Also if you are using maven add to maven-compiler-plugin configuration -> annotationProcessors -> annotationProcessor: lombok.launch.AnnotationProcessorHider$AnnotationProcessor
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>${maven.plugin.compiler.version}</version> <configuration> <compilerVersion>${java.version}</compilerVersion> <source>${java.version}</source> <target>${java.version}</target> <annotationProcessors> <annotationProcessor>lombok.launch.AnnotationProcessorHider$AnnotationProcessor</annotationProcessor> </annotationProcessors> </configuration> </plugin>
Make sure these two requirements are satisfied:
Enable annotation processing,
Preferences > Build, Execution, Deployment > Compiler > Annotation Processors > Enable annotation processing
Lombok plugin is installed and enabled for your project.
After spending far too long troubleshooting this, I found a simple workaround which ensures IntelliJ processes Lombok annotations correctly during builds.
The gradle-lombok plugin is not necessary for this workaround. Your build.gradle only requires the following:
dependencies {
compileOnly("org.projectlombok:lombok:1.16.18")
}
The workaround is to turn on the following IntelliJ setting:
- Open IntelliJ preferences/settings.
- Navigate to
Build, Execute, Deployment > Build Tools > Gradle > Runner - Check the box labeled
Delegate IDE build/run actions to gradle
Benefits of this workaround compared to other solutions on this page:
- No annotation processing necessary!
- Able to use the Java compiler of your choice (no Eclipse compiler necessary)
- No use of buggy gradle-lombok plugin (although perhaps someone else can solve this)
- No VM options necessary
- No hard-coded paths to lombok jar
One downside is that IntelliJ will no longer use its own test runner. Instead, tests are always run through Gradle.
None of the advanced answers to this question resolved the problem for me.
I managed to solve the problem by adding a dependencie to lombok in the pom.xml file, i.e. :
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.12</version>
</dependency>
I am using IntelliJ 2016.3.14 with maven-3.3.9
Hope my answer will be helpful for you
I followed this procedure to get ride of a similar/same error.
mvn idea:clean
mvn idea:idea
After that I could build both from the IDE intellij and from command line.
On Itellij 15 CE, it's enough to just install Lombok Plugin (no additional configuration required).
I am unable to get this working with the javac compiler, and I get the same error.
Error:(9, 14) java: package lombok does not exist
I have enabled annotation processor, and have also tried rebuilding the project, invalidate cache/restart. Doesn't help.
I did however get it to work partially with eclipse compiler. I say partial because although the build passes successfully, the editor still complains about "Cannot resolve symbol".
Idea - 15.04 community edition Lombok - 1.16.6 Lombok plugin (https://github.com/mplushnikov/lombok-intellij-plugin) - 0.9.8 JDK - 1.8.0_51
Update: Ok, I finally got this working. Mine was a gradle project, and lombok was configured as a custom "provided" configuration. Worked fine after adding this in build.gradle
idea {
module {
scopes.PROVIDED.plus += [configurations.provided]
}
}
So, 3 steps
- Install Lombok plugin from File->Settings->Plugins
- Enable Annotation Processor (javac compiler works too)
- lombok을 사용자 정의 구성으로 추가하는 경우에 대비하여 build.gradle 또는 pom.xml이 업데이트되도록하십시오.
참고 URL : https://stackoverflow.com/questions/24006937/lombok-annotations-do-not-compile-under-intellij-idea
'Programing' 카테고리의 다른 글
| 'xp_cmdshell'SQL Server 사용 (0) | 2020.05.25 |
|---|---|
| NameError : 이름 'reduce'가 파이썬에서 정의되지 않았습니다 (0) | 2020.05.25 |
| Java 코드 바이트를 16 진수로 변환하려면 (0) | 2020.05.25 |
| C # 코드에서 WPF 텍스트 상자의 배경색 설정 (0) | 2020.05.25 |
| UnicodeDecodeError : 'utf-8'코덱이 바이트를 디코딩 할 수 없습니다 (0) | 2020.05.25 |