使用lombok包可以将实类的get/set方法省略

1.在pom.xml文件里导入包

 
        
            org.projectlombok
            lombok
            1.18.4
            provided
        ```
2。编写实体类

package entity;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.Id;
import javax.persistence.Table;

@Table(name = “userinfo”)
@Setter
@Getter
public class UserDTO{
@Id
private Integer uid;
private String username;
private Integer age;
private String sex;
private String nation;
private String motion;
private String food;
private Double consume;
private Double balance;

@Override
public String toString() {
    return "UserInfo{" +
            "uid=" + uid +
            ", username='" + username + '\'' +
            ", age=" + age +
            ", sex='" + sex + '\'' +
            ", nation='" + nation + '\'' +
            ", motion='" + motion + '\'' +
            ", food='" + food + '\'' +
            ", consume=" + consume +
            ", balance=" + balance +
            '}';
}

}


你可能感兴趣的:(java,优化)