문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판 이전 판 다음 판 | 이전 판 | ||
java:lombok [2020/07/09 12:39] kwon37xi |
java:lombok [2022/06/23 11:10] (현재) kwon37xi |
||
---|---|---|---|
줄 4: | 줄 4: | ||
* [[java: | * [[java: | ||
* [[java: | * [[java: | ||
+ | * [[java: | ||
* [[http:// | * [[http:// | ||
* [[https:// | * [[https:// | ||
줄 9: | 줄 10: | ||
===== Gradle-Lombok ===== | ===== Gradle-Lombok ===== | ||
- | * [[https://github.com/franzbecker/gradle-lombok|gradle-lombok plugin]] | + | * [[https://projectlombok.org/setup/gradle|lombok setup gradle]] |
+ | * [[https:// | ||
* 혹은 다음과 같이 직접 설정< | * 혹은 다음과 같이 직접 설정< | ||
compileOnly ' | compileOnly ' | ||
줄 34: | 줄 36: | ||
===== Maven 설정 ===== | ===== Maven 설정 ===== | ||
* http:// | * http:// | ||
- | * Java 1.6 이상에서만 작동한다. Java 코드가 1.6임을 명시하라.< | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | <!-- < | ||
- | </ | ||
- | </ | ||
- | </ | ||
- | </ | ||
- | |||
- | </ | ||
* 만약 JPA Annotation Processor 때문에 maven-compiler-plugin 의** compilerArgument에 -proc: | * 만약 JPA Annotation Processor 때문에 maven-compiler-plugin 의** compilerArgument에 -proc: | ||
줄 96: | 줄 82: | ||
* 1.4 이하 Ant 태스크 : '' | * 1.4 이하 Ant 태스크 : '' | ||
* 1.6 이상 Ant 태스크 : '' | * 1.6 이상 Ant 태스크 : '' | ||
+ | |||
+ | ==== Boolean 필드 문제 ==== | ||
+ | * [[https:// | ||
+ | * '' | ||
+ | * '' | ||
+ | * 따라서 '' | ||
+ | * '' | ||
+ | |||
+ | ===== Upgrade 주의점 ===== | ||
+ | * [[https:// | ||
+ | |||
+ | ==== 1.16.20 @ConstructorProperties ==== | ||
+ | * 이 시점 이후부터 '' | ||
+ | * [[https:// | ||
+ | * 기본 생성자가 없을 경우, [[java: | ||
+ | * '' | ||
+ | |||
+ | > BREAKING CHANGE: lombok config key lombok.anyConstructor.suppressConstructorProperties is now deprecated and defaults to true, that is, by default lombok no longer automatically generates @ConstructorProperties annotations. New config key lombok.anyConstructor.addConstructorProperties now exists; set it to true if you want the old behavior. Oracle more or less broke this annotation with the release of JDK9, necessitating this breaking change. | ||
+ | |||
+ | ==== 1.18.4 field annotation 들이 getter/ | ||
+ | * 1.18.4 이상 버전은 field 에 지정한 '' | ||
+ | * 문제는 기존에 복제를 안해주는 버전으로 응답을 내려줄때, | ||
+ | |||
+ | >> BREAKING CHANGE: Lombok will now always copy specific annotations around (from field to getter, from field to builder ' | ||
+ | |||
+ | === 구버전 === | ||
+ | |||
+ | <code java> | ||
+ | @JsonProperty(" | ||
+ | private int isXxx; | ||
+ | |||
+ | -> 진짜 생성은 | ||
+ | |||
+ | @JsonProperty(" | ||
+ | private int isXxx; | ||
+ | |||
+ | public void setXxx(int xxx) { | ||
+ | this.isXxx = xxx; | ||
+ | } | ||
+ | |||
+ | -> 이로 인해서 JSON 에 '' | ||
+ | </ | ||
+ | |||
+ | === 신 버전 Lombok === | ||
+ | <code java> | ||
+ | @JsonProperty(" | ||
+ | private int isXxx; | ||
+ | |||
+ | -> 진짜 생성은 | ||
+ | |||
+ | @JsonProperty(" | ||
+ | private int isXxx; | ||
+ | |||
+ | // 아래 setter 에도 @JsonProperty 가 붙어버림 | ||
+ | @JsonProperty(" | ||
+ | public void setXxx(int isXxx) { | ||
+ | this.isXxx = isXxx; | ||
+ | } | ||
+ | </ | ||
+ | * 해결책은 getter/ | ||
+ | * 여기서 진짜 문제는 Jackson 이 '' | ||
+ | * Java Bean/ | ||
+ | * 그런데 많은 사람들이 필드 이름을 지을 때 '' | ||
+ | * 따라서 이 문제는 **is로 시작하는 boolean 필드** 에서만 발생한다. | ||
+ |