用hibernate通过xml文件建表
1 编写java类
3 在hibernate.hbm.xml文件中添加
<property name="hbm2ddl.auto">create</property>
<mapping resource="com/student/bean/Course.hbm.xml"/>package com.student.hibernate;import org.hibernate.cfg.Configuration;import org.hibernate.tool.hbm2ddl.SchemaExport;public class Test { public static void main(String args[])throws Exception{ Configuration cfg=new Configuration().configure(); SchemaExport export=new SchemaExport(cfg); export.create(true, true); }}
5 运行main,即可建表course