为什么龙目岛@Builder与此构造函数不兼容?
我有这个简单的代码:
@Data
@Builder
public class RegistrationInfo {
private String mail;
private String password;
public RegistrationInfo(RegistrationInfo registrationInfo) {
this.mail = registrationInfo.mail;
this.password = registrationInfo.password;
}
}
首先,我只使用龙目岛注释,一切都很好。但是我添加了构造函数,代码不再编译。错误是:@Builder
Error:(2, 1) java: constructor RegistrationInfo in class com.user.RegistrationInfo cannot be applied to given types;
required: com.user.RegistrationInfo
found: java.lang.String,java.lang.String
reason: actual and formal argument lists differ in length
所以我有两个问题:
- 为什么龙目岛与此构造函数不兼容?
@Builder
- 如何进行代码编译,同时考虑到我需要生成器和构造函数?