Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lombok과 mapstruct가 충돌나는 현상 #38

Closed
seungheoni opened this issue Jun 1, 2023 · 0 comments · Fixed by #40
Closed

lombok과 mapstruct가 충돌나는 현상 #38

seungheoni opened this issue Jun 1, 2023 · 0 comments · Fixed by #40
Assignees
Labels
bug Something isn't working

Comments

@seungheoni
Copy link
Owner

seungheoni commented Jun 1, 2023

현상 확인

  • 아래와 같이 build.gradle 구성시
    // 도메인,dto 손쉬운 변환을 위한 라이브러리
    implementation 'org.mapstruct:mapstruct:1.5.3.Final'
    annotationProcessor 'org.mapstruct:mapstruct-processor:1.5.3.Final'

    // lombok
    compileOnly 'org.projectlombok:lombok:1.18.26'
    annotationProcessor 'org.projectlombok:lombok:1.18.26'

조치

  • gpt와 구글링을 찾아서 보니 build.gradle의 순서가 문제였다
Lombok은 컴파일 시점에 코드를 생성하며, 이로 인해 IDE나 다른 도구가 생성된 코드를 인식하지 못하는 경우가 있습니다. MapStruct도 이러한 도구 중 하나로, Lombok에 의해 생성된 getter/setter 메소드를 인식하지 못하면 이를 문제로 인식할 수 있습니다.

이 문제를 해결하기 위한 한 가지 방법은 Lombok과 MapStruct의 동작 순서를 조정하는 것입니다. 예를 들어, Lombok이 먼저 동작하도록 설정하여 Lombok에 의해 생성된 코드가 MapStruct에 의해 사용될 수 있도록 할 수 있습니다.
  • 따라서 아래와 같이 순서를 변경했더니 문제가 더이상 발생하지 않았음
    // lombok
    compileOnly 'org.projectlombok:lombok:1.18.26'
    annotationProcessor 'org.projectlombok:lombok:1.18.26'

    // 도메인,dto 손쉬운 변환을 위한 라이브러리
    implementation 'org.mapstruct:mapstruct:1.5.3.Final'
    annotationProcessor 'org.mapstruct:mapstruct-processor:1.5.3.Final'
@seungheoni seungheoni self-assigned this Jun 1, 2023
@seungheoni seungheoni added the bug Something isn't working label Jun 1, 2023
@seungheoni seungheoni linked a pull request Jun 3, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant