How to specify that fields are not added to the toString when JAVA Lombok uses @ Data

topic description

how to specify that fields are not added to toString

when JAVA Lombok uses @ Data

related codes

/ / Please paste the code text below (do not replace the code with pictures)

import lombok.Data;
import java.io.Serializable;

@Data
public class User implements Serializable {

    private Integer id;

    private String name;

    private String code;

}

for example, the User class now uses @ Data, when using new User (). ToString (), the output string has three id/name/code fields in it, but what should I do if I don"t want the code field in it?

Feb.21,2022

exclude @ ToString (exclude= "code")


By default, all non-static fields will be printed. If you want to skip some fields, you can annotate these fields with @ ToString.Exclude


annotate @ ToString.Exclude directly above the fields to be excluded

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3ab89-4ee9e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3ab89-4ee9e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?