使用@Data、@Builder的注意点

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

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

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

    public AgentVO() {
    }

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

@Data
@RequiredArgsConstructor
@NoArgsConstructor
目录
相关文章
|
8月前
|
JavaScript
Vue报错 Invalid default value for prop “list“: Props with type Object/Array must use a factory
Vue报错 Invalid default value for prop “list“: Props with type Object/Array must use a factory
376 0
org.activiti.engine.ActivitiException: Couldn't deserialize object in variable 'application'
org.activiti.engine.ActivitiException: Couldn't deserialize object in variable 'application'
|
8月前
Cannot load keys from store: class path resource
Cannot load keys from store: class path resource
405 0
|
8月前
FeignClient【问题】Cannot deserialize value of type``from Object value (token `JsonToken.START_OBJECT`)
FeignClient【问题】Cannot deserialize value of type``from Object value (token `JsonToken.START_OBJECT`)
951 0
DevTools failed to load source map: Could not load content for…System error: net::ERR_FILE_NOT_FOUN
DevTools failed to load source map: Could not load content for…System error: net::ERR_FILE_NOT_FOUN
|
JSON 前端开发 数据格式
org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize instance of `object` out of START_ARRAY token
讲述如何处理 org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize instance of `object` out of START_ARRAY token的问题
 org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize instance of `object` out of START_ARRAY token
Could not resolve element type of Iterable type xxxxx.RequestParam java.util.List<?>. Not declared?
Could not resolve element type of Iterable type xxxxx.RequestParam java.util.List<?>. Not declared?
Could not resolve element type of Iterable type xxxxx.RequestParam java.util.List<?>. Not declared?
|
JavaScript
Object.assign(this.$data, this.$options.data())-vue清空数据
Object.assign(target,...source)是es6新增的方法,可以合并对象,用于将所有可枚举属性的值从一个或多个源对象复制到目标对象,它将返回目标对象,target:目标对象,source:源对象,通过Object.assign方法,把source合并给target,如果目标对象中的属性名与源对象中的属性名相同时,则属性将被源对象中的属性覆盖,然后返回target对象;
234 0
|
Python
Flask - 访问返回字典的接口报错:The view function did not return a valid response. The return type must be a string, tuple, Response instance, or WSGI callable, but it was a dict.
Flask - 访问返回字典的接口报错:The view function did not return a valid response. The return type must be a string, tuple, Response instance, or WSGI callable, but it was a dict.
1557 0
Flask - 访问返回字典的接口报错:The view function did not return a valid response. The return type must be a string, tuple, Response instance, or WSGI callable, but it was a dict.
|
开发工具 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.
220 0
解决Error:Could not determine the class-path for interface com.android.builder.model.AndroidProject.