java.lang.NoSuchMethodException: userAuth.User.()

前端 未结 4 1560
小蘑菇
小蘑菇 2020-12-10 00:13

I have the class with validation:

public class User {
    @Size(min=3, max=20, message=\"User name must be between 3 and 20 characters long\")
    @Pattern(r         


        
4条回答
  •  醉话见心
    2020-12-10 00:51

    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.

提交回复
热议问题