Hibernate出现org.hibernate.InstantiationException: No default constructor for entity解决方法

Error performing load command : org.hibernate.InstantiationException: No default constructor for entity: : entity.User
【原因】

The no-argument constructor, which is also a JavaBean convention, is a requirement for all persistent classes. Hibernate needs to create objects for you, using Java Reflection.

所有持久化类必须要求有不带参的构造方法(也是JavaBean的规范)。Hibernate需要使用Java反射为你创建对象。
——来自官方文档《Hibernate Getting Started Guide》

【解决方法】

当实体类声明了其他带参构造方法时,需要显式声明不带参构造方法。

为人:谦逊、激情、博学、审问、慎思、明辨、 笃行
学问:纸上得来终觉浅,绝知此事要躬行
为事:工欲善其事,必先利其器。
态度:道阻且长,行则将至;行而不辍,未来可期
转载请标注出处!
原文地址:https://www.cnblogs.com/ios9/p/15696266.html