1. 程式人生 > >java.lang.NoSuchMethodException: 實體類.<init>()

java.lang.NoSuchMethodException: 實體類.<init>()

 1 root cause
 2 
 3 org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.hs.model.StudentModel]: No default constructor found; nested exception is java.lang.NoSuchMethodException: com.hs.model.StudentModel.<init>()
 4     org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:108)
5 org.springframework.web.method.annotation.ModelAttributeMethodProcessor.createAttribute(ModelAttributeMethodProcessor.java:136) 6 org.springframework.web.servlet.mvc.method.annotation.ServletModelAttributeMethodProcessor.createAttribute(ServletModelAttributeMethodProcessor.java:81) 7 org.springframework.web.method.annotation.ModelAttributeMethodProcessor.resolveArgument(ModelAttributeMethodProcessor.java:101)
8 org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:77) 9 org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:162) 10 org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:123)
11 org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104) 12 org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745) 13 org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686) 14 org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80) 15 org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925) 16 org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856) 17 org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936) 18 org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:838) 19 javax.servlet.http.HttpServlet.service(HttpServlet.java:647) 20 org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812) 21 javax.servlet.http.HttpServlet.service(HttpServlet.java:728) 22 org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393) 23 org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) 24 org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 25 root cause 26 27 java.lang.NoSuchMethodException: com.hs.model.StudentModel.<init>() 28 java.lang.Class.getConstructor0(Class.java:2902) 29 java.lang.Class.getDeclaredConstructor(Class.java:2066) 30 org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:105) 31 org.springframework.web.method.annotation.ModelAttributeMethodProcessor.createAttribute(ModelAttributeMethodProcessor.java:136) 32 org.springframework.web.servlet.mvc.method.annotation.ServletModelAttributeMethodProcessor.createAttribute(ServletModelAttributeMethodProcessor.java:81) 33 org.springframework.web.method.annotation.ModelAttributeMethodProcessor.resolveArgument(ModelAttributeMethodProcessor.java:101) 34 org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:77) 35 org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:162) 36 org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:123) 37 org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104) 38 org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745) 39 org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686) 40 org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80) 41 org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925) 42 org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856) 43 org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936) 44 org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:838) 45 javax.servlet.http.HttpServlet.service(HttpServlet.java:647) 46 org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812) 47 javax.servlet.http.HttpServlet.service(HttpServlet.java:728) 48 org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393) 49 org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) 50 org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
錯誤程式碼

 

 

有人說是實體類中沒有無參構造方法

 https://blog.csdn.net/zhengsaisai/article/details/79626895