Java lombok 使用 @Data 遇到 extends 會發生警告要如何處理( Multiple markers at this line)

如果遇到

Multiple markers at this line
就表示你的父類已經有 @Data 了

範例

    @Data
    public static class Val implements OType {
        private String clazz;

        public Val() {
            clazz = this.getClass().getName();
        }
    }

    @Data
    public static class RefVal extends Val {
        private VarLv lv;
        private String name;
    }
這時候就會出現
Multiple markers at this line

如何解決

增加
@EqualsAndHashCode(callSuper = false)
此 Annotation 即可
完整如下
    @Data
    public static class Val implements OType {
        private String clazz;

        public Val() {
            clazz = this.getClass().getName();
        }
    }

    @Data
    @EqualsAndHashCode(callSuper = false)
    public static class RefVal extends Val {
        private VarLv lv;
        private String name;
    }




md code:

留言

這個網誌中的熱門文章

angular 如何Http 如何設定 CORS (Cross-Origin Resource Sharing)

Google Map 單車路徑計算坡度和角度小工具

Google URL Shortener API 快速教學