1.创建好hibernate.cfg.xml和映射文件,实体类 以及get set方法
2.main方法中:
1)Configuration cfg=new Configuration().Configure();
SchemaExport export=new SchemaExport(cfg);
export.create(true,true);
2)在hibernate.cfg.xml配置文件中添加属性:<property name="hbm.2ddl.auto">true</property>
在程序首次运行会自动建立表,建立表后应该去掉