java.lang.NoSuchMethodException: userAuth.User.<init>() java.lang.NoSuchMethodException: userAuth.User.<init>() spring spring

java.lang.NoSuchMethodException: userAuth.User.<init>()


The message java.lang.NoSuchMethodException: userAuth.User.<init>() means that someone tried to call a constructor without any parameters. Adding a default constructor should solve this problem:

public class User {    public User() {    }    ..}


If the User class is a non-static inner class of another class (e.g. UserAuth), then the message could arise if the User class is attempted to be instantiated before the external class is instantiated. In this case the null-arg constructor might be there in the code but will not be found, since the external class does not exist yet. A solution could be to extract the inner class into an independent class, to make it static or to ensure the initialization of the external class happens before that of the inner class.


Add constructor without parameters:

public class User {  ...  public User() {}  ...}