在数据库URL加characterEncoding=utf-8
<hibernate-configuration>
<session-factory>
<!-- 数据库驱动 -->
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<!-- 数据库url,characterEncoding=utf-8 -->
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/test?characterEncoding=utf-8</property>
<!-- 数据库账号 -->
<property name="hibernate.connection.username">root</property>
<!-- 数据库密码 -->
<property name="hibernate.connection.password">12345</property>
<!-- 数据库方言 -->
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- 将hibernate生成的SQL语句打印 到控制台 -->
<property name="hibernate.show_sql">true</property>
<!-- 将hibernate生成的sql语句格式化(语法缩进) -->
<property name="hibernate.format_sql">true</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<!-- 引入orm元数据 路径书写: 填写src下的路径 -->
<mapping resource="com/csgg/po/Customer.hbm.xml" />
</session-factory>
</hibernate-configuration>