建一个main方法;
Configuration cfg = ( new Configuration()).configure(new File("src/hibernate.cfg.xml"));
SchemaExport export = new SchemaExport(cfg);
export.create(true, true);
执行就OK了;
执行之前要先建好数据库
导入的类
import java.io.File;
import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;