繁体   English   中英

Lombok Maven与Eclipse或STS中的Lombok不同

[英]Lombok Maven different of Lombok in Eclipse or STS

我在Maven编译和Eclipse编译之间有差值。 用Maven可以,但是不能用Eclipse。

在Eclipse进行编译时,它会丢失具有两个参数的构造函数上的@ConstructorProperties({ "id", "profile" })注释。

我的Java文件:

@Data
@AllArgsConstructor
public class Author {
    private String id;
    private String profile;
}

Maven的全班授课(确定):

import java.beans.ConstructorProperties;

public class Author {
    private String id;
    private String profile;

    public void setId(String id) {
        this.id = id;
    }

    public void setProfile(String profile) {
        this.profile = profile;
    }

    @Override
    public boolean equals(Object o) {
        if (o == this) {
            return true;
        }
        if (!(o instanceof Author)) {
            return false;
        }
        final Author other = (Author) o;
        if (!other.canEqual(this)) {
            return false;
        }
        final Object this$id = getId();
        final Object other$id = other.getId();
        if (this$id == null ? other$id != null : !this$id.equals(other$id)) {
            return false;
        }
        final Object this$profile = getProfile();
        final Object other$profile = other.getProfile();
        return this$profile == null ? other$profile == null : this$profile.equals(other$profile);
    }

    protected boolean canEqual(Object other) {
        return other instanceof Author;
    }

    @Override
    public int hashCode() {
        final int PRIME = 59;
        int result = 1;
        final Object $id = getId();
        result = result * 59 + ($id == null ? 43 : $id.hashCode());
        final Object $profile = getProfile();
        result = result * 59 + ($profile == null ? 43 : $profile.hashCode());
        return result;
    }

    @Override
    public String toString() {
        return "Author(id=" + getId() + ", profile=" + getProfile() + ")";
    }

    @ConstructorProperties({ "id", "profile" })
    public Author(String id, String profile) {
        this.id = id;
        this.profile = profile;
    }

    public String getId() {
        return id;
    }

    public String getProfile() {
        return profile;
    }
}

Eclipse的完整课程:

public class Author {
    private String id;
    private String profile;

    public String getId() {
        return id;
    }

    public String getProfile() {
        return profile;
    }

    public void setId(String id) {
        this.id = id;
    }

    public void setProfile(String profile) {
        this.profile = profile;
    }

    @Override
    public boolean equals(Object o) {
        if (o == this) {
            return true;
        }
        if (!(o instanceof Author)) {
            return false;
        }
        final Author other = (Author) o;
        if (!other.canEqual(this)) {
            return false;
        }
        final Object this$id = getId();
        final Object other$id = other.getId();
        if (this$id == null ? other$id != null : !this$id.equals(other$id)) {
            return false;
        }
        final Object this$profile = getProfile();
        final Object other$profile = other.getProfile();
        return this$profile == null ? other$profile == null : this$profile.equals(other$profile);
    }

    protected boolean canEqual(Object other) {
        return other instanceof Author;
    }

    @Override
    public int hashCode() {
        final int PRIME = 59;
        int result = 1;
        final Object $id = getId();
        result = result * 59 + ($id == null ? 43 : $id.hashCode());
        final Object $profile = getProfile();
        result = result * 59 + ($profile == null ? 43 : $profile.hashCode());
        return result;
    }

    @Override
    public String toString() {
        return "Author(id=" + getId() + ", profile=" + getProfile() + ")";
    }

    public Author(String id, String profile) {
        this.id = id;
        this.profile = profile;
    }
}

@tobias_k查找解决方案:

Eclipse需要安装与Maven项目使用的版本相同的Lombok。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM