hibernate中使用schemaExport生成数据表报错解决方法
来源:互联网 发布:linux统计登陆用户数 编辑:程序博客网 时间:2024/04/26 18:29
【错误详情】
java.lang.UnsupportedOperationException: Attempt to use unsupported SchemaExport constructor accepting org.hibernate.cfg.Configuration; one of the forms accepting org.hibernate.boot.spi.MetadataImplementor should be used instead。
【解决方法】
1.很多教材是教你这么写的:
SchemaExport schemaExport = new SchemaExport(new Configuration().configure());schemaExport.create(true, true);
因为我们现在基本都是使用hibernate 5.x,所以当你这么写的时候,IDE会提醒你这种方法已经不推荐使用了。
2.解决方法:将以上代码改成以下代码:
ServiceRegistry serviceRegistry = (ServiceRegistry) new StandardServiceRegistryBuilder().configure().build();MetadataImplementor metadataImplementor = (MetadataImplementor) new MetadataSources(serviceRegistry).buildMetadata();SchemaExport export = new SchemaExport(serviceRegistry,metadataImplementor);export.create(true, true);
重新运行,(如果你的hibernate和数据库驱动的jar已经正确导入),应该是OK了。
0 0
- hibernate中使用schemaExport生成数据表报错解决方法
- hibernate使用SchemaExport自动生成数据表
- Hibernate 使用SchemaExport自动生成表
- Hibernate中使用SchemaExport&nbsp…
- hibernate 5.0中如何使用SchemaExport
- 使用SchemaExport生成数据表
- Hibernate使用SchemaExport和AnnotationConfiguration生成表结构
- Hibernate(一)——使用SchemaExport生成数据表
- Hibernate ORM入门02-使用SchemaExport生成数据表
- Hibernate整合Spring后,如何使用SchemaExport生成数据库表
- hibernate使用SchemaExport生成对应的数据库表
- Navicate使用SQL新建数据表报错
- 使用SchemaExport生成数据库表
- 利用hibernate中的SchemaExport生成数据表
- 利用hibernate中的SchemaExport生成数据表
- Hibernate之SchemaExport+配置文件生成表结构
- Hibernate中使用SchemaExport来自动生成数据库中的表时,控制台有sql语句,但是数据库中无新建的表
- hibernate中annotation方式SchemaExport无法生成表的原因(ORA-02261)
- tabview
- ocp-174
- 返回顶部按钮实现
- ocp-175
- 环境光传感器(ALS)背光控制解决方案
- hibernate中使用schemaExport生成数据表报错解决方法
- ocp-176
- iOS开发系列课程(08) --- 事件处理详解和手势操作
- ocp-177
- 以代码爱好者角度来看AMD与CMD
- mysql,oracle批量插入,更新
- ocp-178
- ocp-179
- ocp-180