org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine
来源:互联网 发布:unity3d麻将胡牌 编辑:程序博客网 时间:2024/05/17 23:52
学习hibernate过程中遇到了不少问题,这也是作为一个菜鸟程序员一定会遇到的问题,就是粗心,这不,又出事了。
这是在编写hibernate测试的时候遇到的。
问题:以下就粘贴主要错误提示
org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
可能原因:Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when ‘hibernate.dialect’ not set
错误原因:
public class HibernateTest{ @Test public void test(){ //1.加载配置文件 Configuration configuration = new Configuration(); //如果不使用configure()方法,这时hibernate会在classpath下面寻找hibernate.properties文件,如果没有找到该文件,系统会打印如下信息并抛出HibernateException异常。 //2.创建SessionFactory工厂对象 SessionFactory sessionFactory = configuration.buildSessionFactory(); //3.获取Session对象 Session session = sessionFactory.getCurrentSession(); //4.执行操作 Student student = new Student("张三",20); session.save(student); }}
解决方法:
直接写上这行代码就行了
Configuration configuration = new Configuration().configure();
//因为这个位置漏写了得到.configure();产生了以下错误
总结:问题虽小,但也是可以避免的,这样也能为编程节约不少时间,如果问题能够避免,为什么还要去自找呢?归根到底,还是粗心惹的祸,所以敲代码还需谨慎啊。
0 0
- org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine
- org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine
- Unable to create requested service [org.hibernate.engine.spi.CacheImple
- hibernate异常Unable to create requested service [org.hibernate.engine.spi.CacheImple
- Hibernate:Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
- hibernate 报错Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
- Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
- tomcat 启动报错, Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
- Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
- Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
- Unable to create requested service [org.hibernate.service.jdbc.connections.spi.ConnectionProvider]
- Unable to create requested service [org.hibernate.service.jdbc.connections.spi.ConnectionProvider]
- Hibernate提示service.spi.ServiceException
- org.hibernate.service.UnknownServiceException: Unknown service requested [org.hibernate.stat.spi.Sta
- SSH 整合 nested exception is org.hibernate.service.spi.ServiceException错误
- 整合spring4和hibernate4出现问题———org.hibernate.service.spi.ServiceException:
- org.hibernate.service.jta.platform.spi.JtaPlatform
- Spring+Hibernate Error: org.hibernate.service.UnknownUnwrapTypeException: Cannot unwrap to requested
- 分类算法之朴素贝叶斯分类(Naive Bayesian classification)
- LVS基本配置
- cookie中转注入,使用sqlmap中转注入
- laravel学习笔记(2)— Laravel中的MVC
- CCF NOI1117 排序
- org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine
- qt迁移linux有关中文字体,中文显示的问题(转)
- Ubuntu MATE for the Raspberry Pi 2 and Raspberry Pi 3
- earn the python in hard way习题21~25的附加习题
- JavaScript 用法(一)
- 【redis】关系型数据库 VS 非关系型数据库
- cf 410
- github使用——1
- Spring事务管理、Aop