Image() is already defined in class during Maven build using Lombok

假如想象 提交于 2019-12-23 11:54:32

问题


The below code is causing a compilation error (Image() is already defined in class) on the line with @NoArgsConstructor when building with Maven.

import lombok.Data;
import lombok.NoArgsConstructor;

// tag::code[]
@Data
@NoArgsConstructor
public class Image {

    private int id;
    private String name;

    public Image(int id, String name) {
        this.id = id;
        this.name = name;
    }
} 

What is causing this problem and how can I fix it?

EDIT: Lombok version is 1.16.22.


回答1:


Due to a bug in Lombok v1.16.22, specifying both @Data and @NoArgsConstructor on a class triggered an error. This has been fixed in major release v1.18.0.

In the Lombok changelog, we find the following under v1.18.0:

BUGFIX: Do not generate a private no-args constructor if that breaks the code. Issue #1703, Issue #1704, Issue #1712



来源:https://stackoverflow.com/questions/51202966/image-is-already-defined-in-class-during-maven-build-using-lombok

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!