不可否认,写xml经常性手抖是一种锻炼手部肌肉的好办法。
- 报错内容:
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name ‘sessionFactory’ defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.
HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
- 造成原因:
Caused by: org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
Caused by: java.lang.reflect.InvocationTargetException
Caused by: org.hibernate.PropertyNotFoundException: Could not find a getter for stock in class spring.hibernate.entities.Book
- 解决办法:
1)可能是缺少javassist.jar包,需要导入该jar包。
2)查看hibernate映射entities类,检查映射字段是否完全匹配。
- 写在后面:
Caused by: org.hibernate.PropertyNotFoundException: Could not find a getter for stock in class spring.hibernate.entities.Book
这里说是stock 的getter 方法找不到,我看了下都写了getter方法,
又检查了一下 .hbm.xml 文件,果然,是自己手抖了下:
这太明显了吧,就这,就这…
删了这两边的小空格,简单的错误就是这么容易解决。