문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판 이전 판 다음 판 | 이전 판 다음 판 양쪽 다음 판 | ||
java:lombok [2011/06/14 17:04] kwon37xi |
java:lombok [2021/02/10 23:01] kwon37xi [1.18.4 field annotation 들이 getter/setter 로 복제됨] |
||
---|---|---|---|
줄 2: | 줄 2: | ||
* http:// | * http:// | ||
* getter/ | * getter/ | ||
+ | * [[java: | ||
+ | * [[java: | ||
+ | * [[http:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | |||
+ | ===== Gradle-Lombok ===== | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * 혹은 다음과 같이 직접 설정< | ||
+ | compileOnly ' | ||
+ | annotationProcessor ' | ||
+ | |||
+ | testCompileOnly ' | ||
+ | testAnnotationProcessor ' | ||
+ | </ | ||
+ | |||
+ | ===== javac 메모리 문제 ===== | ||
+ | * [[http:// | ||
+ | * **'' | ||
+ | |||
+ | ===== Disable Field ===== | ||
+ | * '' | ||
+ | // 모든 필드에 대해 Getter/ | ||
+ | @Data | ||
+ | public class Person { | ||
+ | @Setter(AccessLevel.NONE) | ||
+ | private int age; | ||
+ | } | ||
+ | </ | ||
===== Maven 설정 ===== | ===== Maven 설정 ===== | ||
* http:// | * http:// | ||
- | * Java 1.6 이상에서만 작동한다. Java 코드가 1.6임을 명시하라.< | + | * 만약 JPA Annotation Processor 때문에 maven-compiler-plugin |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | <!-- <compilerArgument>-proc:none</ | + | |
- | </ | + | |
- | </ | + | |
- | </ | + | |
- | </ | + | |
+ | ===== 주의점 ===== | ||
+ | * 상호 참조하는 객체의 경우 toString() 호출시 Stack Overflow 가 발생할 수 있다. 한쪽 객체에서 다른 쪽 객체에 대해 '' | ||
+ | * '' | ||
+ | |||
+ | ===== PMD 문제 회피 ===== | ||
+ | * Lombok으로 Getter/ | ||
+ | @Data | ||
+ | @SuppressWarnings(" | ||
+ | public class LombokUseClass { | ||
+ | } | ||
</ | </ | ||
- | * 만약 JPA Annotation Processor | + | * '' |
+ | @Data | ||
+ | @SuppressWarnings(" | ||
+ | public class LombokUsedClass { | ||
+ | private String field; | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ===== Checkstyle | ||
+ | * HideUtilityClassConstructor <code java> | ||
+ | @SuppressWarnings(" | ||
+ | </ | ||
+ | |||
+ | ===== equals & hashCode Code Coverage ===== | ||
+ | * [[java: | ||
+ | * 다른 클래스를 상속할 때, 부모 클래스의 '' | ||
+ | @EqualsAndHashCode(callSuper = true, of = {}) | ||
+ | </ | ||
+ | * 여기서 '' | ||
+ | |||
+ | ===== Custom Handler ===== | ||
+ | *[[http:// | ||
+ | * [[http:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | |||
+ | ===== Default Value Builder & ETC===== | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | |||
+ | ===== Delombok ===== | ||
+ | * 1.4 이하 Ant 태스크 : '' | ||
+ | * 1.6 이상 Ant 태스크 : '' | ||
+ | |||
+ | ===== Upgrade 주의점 ===== | ||
+ | | ||
+ | |||
+ | ==== 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/ | ||
+ | | ||
+ | | ||
+ | |||
+ | >> 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/ | ||
+ | * 따라서 이 문제는 '' |