使用@Data、@Builder的注意点

简介: 使用@Data、@Builder的注意点

使用@Data注解会成get()和set()方法以及无参构造器。
使用@Builder将会帮助我们成全属性的构造法。
但是如果同时使@Data和@Builder的话,参构造法会被干掉。
解决方案:

  1. 可以在无参构造方法上加@Tolerate注解
    @Tolerate

    public AgentVO() {
    }

2.直接使用无参构造器+有参构造器的方式,@RequiredArgsConstructor 来构建有参,@NoArgsConstructor来构建无参构造器

@Data
@RequiredArgsConstructor
@NoArgsConstructor
目录
相关文章
|
6月前
Cannot load keys from store: class path resource
Cannot load keys from store: class path resource
375 0
org.activiti.engine.ActivitiException: Couldn't deserialize object in variable 'application'
org.activiti.engine.ActivitiException: Couldn't deserialize object in variable 'application'
org.apache.ibatis.builder.IncompleteElementException: Could not find result map com.dao.IndexDao.Use
org.apache.ibatis.builder.IncompleteElementException: Could not find result map com.dao.IndexDao.Use
98 0
|
JavaScript
Object.assign(this.$data, this.$options.data())-vue清空数据
Object.assign(target,...source)是es6新增的方法,可以合并对象,用于将所有可枚举属性的值从一个或多个源对象复制到目标对象,它将返回目标对象,target:目标对象,source:源对象,通过Object.assign方法,把source合并给target,如果目标对象中的属性名与源对象中的属性名相同时,则属性将被源对象中的属性覆盖,然后返回target对象;
211 0
Could not initialize English chunker/Could not load file from classpath: ‘/en-token.bin‘
Could not initialize English chunker/Could not load file from classpath: ‘/en-token.bin‘
101 0
|
开发工具 Android开发
解决Error:Could not determine the class-path for interface com.android.builder.model.AndroidProject.
解决Error:Could not determine the class-path for interface com.android.builder.model.AndroidProject.
206 0
解决Error:Could not determine the class-path for interface com.android.builder.model.AndroidProject.
Lombok - new Object & Object.builder.build 默认值区别?
Lombok - new Object & Object.builder.build 默认值区别?
121 0
组件是默认值报错:Props with type Object/Array must use a factory function to return the default value
组件是默认值报错:Props with type Object/Array must use a factory function to return the default value
352 0
组件是默认值报错:Props with type Object/Array must use a factory function to return the default value
|
C#
C# Base64Helper
原文:C# Base64Helper public static class Base64Helper { /// /// base64字符保存图片到本 /// /// 保存的图片完整路径 /...
996 0