NoSuchMethodException ()

时间:2023-03-09 19:10:27
NoSuchMethodException <init>()

1. Question Description:

SEVERE: Servlet.service() for servlet [dispatcher] in context with path [/newppms] threw exception [Request processing failed;

nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.cdv.ppms.web.model.PpmsUser]:

No default constructor found; nested exception is java.lang.NoSuchMethodException: com.cdv.ppms.web.model.PpmsUser.<init>()] with root cause
java.lang.NoSuchMethodException: com.cdv.ppms.web.model.PpmsUser.<init>()
    at java.lang.Class.getConstructor0(Class.java:2902)
    at java.lang.Class.getDeclaredConstructor(Class.java:2066)

2. Analysis:

As the error message say , default constructor not found.

It must be create Constructor with parameters but not create the Constructor with no parameters,

so the default Constructor was covered.

3. Solution:

Add the default Constructor with no parameters.