这是我的Hibernate.cfg.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<!-- 先配置sessionFactory标签,一个数据库对应一个SessionFactory标签 -->
<session-factory>
<!-- 必须要配置的参数有5个,4大参数,数据库的方言 -->
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql:///hibernate_day01</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">root</property>
<!-- 数据库的方言 -->
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- 可选配置 -->
<!-- 显示sql语句,在控制台显示 -->
<property name="hibernate.show_sql">true</property>
<!-- 格式化sql语句 -->
<property name="hibernate.format_sql">true</property>
<!-- 生成表结构 -->
<property name="hibernate.hbm2ddl.auto">update</property>
<!-- 映射配置文件 -->
<mapping resource="com/itheima/demain/Customer.hbm.xml"></mapping>
</session-factory>
</hibernate-configuration>
customer.htm.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<!-- 配置类和表结构的映射 -->
<class name = "com.itheima.demain.Customer" table = "cst_customer">
<!-- 配置id
见到name属性,javaBean的属性
见到colun属性,是表结构的字段
-->
<id name = "cust_id" column="cust_id"></id>
<property name="cust_name" column = "cust_name"></property>
<property name="cust_user_i" column = "cust_user_i"></property>
<property name="cust_create_id" column = "cust_create_id"></property>
<property name="cust_source" column = "cust_source"></property>
<property name="cust_industry" column = "cust_industry"></property>
<property name="cust_level" column = "cust_level"></property>
<property name="cust_linkman" column = "cust_linkman"></property>
<property name="cust_phone" column = "cust_phone"></property>
<property name="cust_mobile" column = "cust_mobile"></property>
</class>
</hibernate-mapping>
测试程序之前没有错误,但是总提示有一个错误,感觉是配置文件的问题,大佬们可以帮忙看一下 |
|