Intellij IDEA 安装lombok及使用详解

参考
https://blog.csdn.net/zhglance/article/details/54931430
https://blog.csdn.net/ghsau/article/details/52334762

跟着https://blog.csdn.net/zhglance/article/details/54931430步骤做完
Intellij IDEA 安装lombok及使用详解_第1张图片
发现get,set等方法都不能识别,这时需要重启idea,然后idea会提示:
Intellij IDEA 安装lombok及使用详解_第2张图片
需要设置下,才能使用注解的功能,如下:
Intellij IDEA 安装lombok及使用详解_第3张图片
设置好了之后,运行便不再报错。
Intellij IDEA 安装lombok及使用详解_第4张图片
且可以看到Student.class如下:

//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

public class Student {
    private String name;
    private int age;
    private String male;
    private String studentNo;

    public Student() {
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void setMale(String male) {
        this.male = male;
    }

    public void setStudentNo(String studentNo) {
        this.studentNo = studentNo;
    }

    public String getName() {
        return this.name;
    }

    public int getAge() {
        return this.age;
    }

    public String getMale() {
        return this.male;
    }

    public String getStudentNo() {
        return this.studentNo;
    }

    public String toString() {
        return "Student(name=" + this.getName() + ", age=" + this.getAge() + ", male=" + this.getMale() + ", studentNo=" + this.getStudentNo() + ")";
    }

    public boolean equals(Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof Student)) {
            return false;
        } else {
            Student other = (Student)o;
            if (!other.canEqual(this)) {
                return false;
            } else {
                Object this$name = this.getName();
                Object other$name = other.getName();
                if (this$name == null) {
                    if (other$name != null) {
                        return false;
                    }
                } else if (!this$name.equals(other$name)) {
                    return false;
                }

                if (this.getAge() != other.getAge()) {
                    return false;
                } else {
                    Object this$male = this.getMale();
                    Object other$male = other.getMale();
                    if (this$male == null) {
                        if (other$male != null) {
                            return false;
                        }
                    } else if (!this$male.equals(other$male)) {
                        return false;
                    }

                    Object this$studentNo = this.getStudentNo();
                    Object other$studentNo = other.getStudentNo();
                    if (this$studentNo == null) {
                        if (other$studentNo != null) {
                            return false;
                        }
                    } else if (!this$studentNo.equals(other$studentNo)) {
                        return false;
                    }

                    return true;
                }
            }
        }
    }

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

    public int hashCode() {
        int PRIME = true;
        int result = 1;
        Object $name = this.getName();
        int result = result * 59 + ($name == null ? 43 : $name.hashCode());
        result = result * 59 + this.getAge();
        Object $male = this.getMale();
        result = result * 59 + ($male == null ? 43 : $male.hashCode());
        Object $studentNo = this.getStudentNo();
        result = result * 59 + ($studentNo == null ? 43 : $studentNo.hashCode());
        return result;
    }
}

你可能感兴趣的:(lombok)