使用@Data、@Builder的注意点

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

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

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

    public AgentVO() {
    }

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

@Data
@RequiredArgsConstructor
@NoArgsConstructor
目录
相关文章
|
2月前
|
数据库 数据库管理
System.ArgumentException:“The specified invariant name ‘System.Data.SQLite‘ wasn‘t found in the list
System.ArgumentException:“The specified invariant name ‘System.Data.SQLite‘ wasn‘t found in the list
28 0
|
2月前
Cannot load keys from store: class path resource
Cannot load keys from store: class path resource
224 0
|
9月前
|
存储 JavaScript 前端开发
什么是 Google Tag Manager 的 Data Layer Object?
什么是 Google Tag Manager 的 Data Layer Object?
|
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 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‘
93 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.
1468 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.
Lombok - new Object & Object.builder.build 默认值区别?
Lombok - new Object & Object.builder.build 默认值区别?
110 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.
182 0
解决Error:Could not determine the class-path for interface com.android.builder.model.AndroidProject.
callbackend entry point - iwfndcl_mgw_request_manager~read_entity
007. callbackend entry point - /iwfnd/cl_mgw_request_manager~read_entity Created by Wang, Jerry, last modified on Jan 06, 2015
callbackend entry point - iwfndcl_mgw_request_manager~read_entity
|
JSON Java 数据格式
How to post a Java object to http end point which accepts json string
How to post a Java object to http end point which accepts json string
How to post a Java object to http end point which accepts json string