/**PageBeginHtml Block Begin **/ /***自定义返回顶部小火箭***/ /*生成博客目录的JS 开始*/ /*生成博客目录的JS 结束*/

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》

【解决方法】

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

 

posted @ 2021-12-16 08:44  一品堂.技术学习笔记  阅读(218)  评论(0编辑  收藏  举报