Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't use lombok @NoArgsConstructor on a class

I'm using Jackson as a Json parser and I'm getting an error:

No suitable constructor found for type ~ can not instantiate from JSON object

So I've tried adding @NoArgsConstructor, but now I'm getting this one:

constructor AccountItem in class AccountItem cannot be applied to given types

Here's my class:

@Getter
@Builder
public class AccountItem {

/**
 * Accounti dentifier
 */
private Long accountId;

/**
 * Account name
 */
private String accountName;

/**
 * Account priority
 */
private int accountPriority;
}

What might be the cause?

like image 503
Maciaz Avatar asked Dec 17 '25 10:12

Maciaz


1 Answers

Add both @AllArgsConstructor and @NoArgsConstructor annotations to your class

like image 135
Denis Zavedeev Avatar answered Dec 19 '25 23:12

Denis Zavedeev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!