Connection cannot be null when 'hibernate.dialect' not set

网友投稿 554 2022-09-01

Connection cannot be null when 'hibernate.dialect' not set

Connection cannot be null when 'hibernate.dialect' not set

使用hibernate在向表中保存数据时虽然保存成功了 但是有异常

仔细查看代码 发现

public static SessionFactory getSessionFactory() { if (sessionFactory == null) { //创建配置对象 config = new Configuration(); //创建服务注册对象 serviceRegistry = new ServiceRegistryBuilder().applySettings( config.getProperties()).buildServiceRegistry(); //创建会话工厂模式 sessionFactory=config.buildSessionFactory(serviceRegistry); } return sessionFactory; }

创建配置对象时 忘记configure()了

修改

config = new Configuration();

config = new Configuration().configure();

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Spring(三)入门案例DI(依赖注入)
下一篇:PHP主流框架优缺点汇总(PHP主流框架)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~