hibernate.cfg.xml文件
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<!-- Generated by MyEclipse Hibernate Tools.                   -->
<hibernate-configuration><session-factory>
<property name="dialect">
org.hibernate.dialect.MySQL5InnoDBDialect
</property>
<property name="connection.url">
jdbc:mysql://localhost:3306/hibernate_db
</property>
<property name="connection.username">root</property>
<property name="connection.password">admin</property>
<property name="connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="myeclipse.connection.profile">mysql</property>
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<property name="hbm2ddl.auto">update</property>
<mapping resource="it/cast/bean/grade.hbm.xml" />
<mapping resource="it/cast/bean/student.hbm.xml" /></session-factory></hibernate-configuration>
另外一个配置文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="it.cast.bean.Grade" table="grade">
<id name="id" type="integer">
<generator class="native"></generator>
</id>
<property name="address1"/>
<property name="address2"/>
<property name="address3"/>
</class>
</hibernate-mapping>
程序
@Test
public void create(){
Configuration conf = HibernateUtil.getConfiguration().configure();
SchemaExport se = new SchemaExport(conf);
se.create(true, true);
}
为什么总说我配置问题,是我的配置哪儿出错了,求各位大佬解