import?org.hibernate.SessionFactory;
import?org.hibernate.cfg.Configuration;
import?org.hibernate.service.ServiceRegistry;
import?org.hibernate.service.ServiceRegistryBuilder;
import?org.hibernate.tool.hbm2ddl.SchemaExport;
import?org.junit.Test;
/**
?*?Created?by?asd73?on?2017/2/25.
?*/
public?class?TestStudents?{
????@Test
????public?void?testSchemaExport(){
????????//默認(rèn)讀取hibernate.cfg.xml文件
????????Configuration?configuration?=?new?Configuration().configure();
????????ServiceRegistry?serviceRegistry?=new?ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();
????????SessionFactory?sessionFactory?=?configuration.buildSessionFactory(serviceRegistry);
????????//?生成并輸出sql到文件(當(dāng)前目錄)和數(shù)據(jù)庫
????????SchemaExport?export?=?new?SchemaExport(configuration);
????????//?創(chuàng)建表結(jié)構(gòu),第一個true?表示在控制臺打印sql語句,第二個true?表示導(dǎo)入sql語句到數(shù)據(jù)庫
????????export.create(true,true);
????}
}在SchemaExport?export?=?new?SchemaExport(configuration);中報錯hibernate包如下,hibernate用的4.2.4為什么報錯
SchemaExport export = new SchemaExport(configuration);報錯?
慕粉2120347094
2017-02-25 16:34:26