Tag Archives: Development error summary

Error reporting when Lombok @ data and @ builder are used together

Lombok @data and @builder are used together
Lombok often uses annotations

error
Sometimes @Builder annotation is added to PO class in order to make the code more elegant when constructing PO class. However, because @Builder and @Data will be used together, the class’s no-argument constructor will be overwritten. As a result, some framework can not successfully assign Data to PO class when operating the database, such as MyBatis.
The solution
Override the no-argument constructor in the class to prevent conflict with Lombok’s annotation, and add the @tolerate annotation on the no-argument constructor
Such as:

@Data
@Builder
public class DataBuilder implements Serializable {

    @Tolerate
    public DataBuilder (){}

}

Lombok uses annotations
A lot of online lecture Here I think a good link
https://www.cnblogs.com/heyonggang/p/8638374.html