使用Hibernate中出现的小错误org.hibernate.service.spi.ServiceException
在使用Hibernate是发现如下的错误:
Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested
service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
原因是在建立SessionFactoy
private static SessionFactory sf; static{ sf=new Configuration().buildSessionFactory(); }
没有加入config()。正确的方法应该是
private static SessionFactory sf; static{ sf=new Configuration().configure().buildSessionFactory(); }
posted on 2017-11-25 22:13 feettable 阅读(1228) 评论(0) 编辑 收藏 举报