hibernate.cfg.xml配置

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration
        PUBLIC "-//hibernate/Hibernate Configurateion DTD 3.0//EN"
    "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<!-- xml比peoperty映射更方便 -->
<!-- SessionFactory配置 -->
    <session-factory>
        <!-- 数据库url -->
        <property name="hibernate.connection.url"  >
            jdbc:sqlserver://localhost:1433;DatabaseName=jx
        </property>
        <!-- 数据库驱动 -->
        <property name="hibernate.connection.driver_class">
             com.microsoft.sqlserver.jdbc.SQLServerDriver
        </property>
        <!-- 数据库用户名 -->
        <property name="hibernate.connection.username">
            sa
        </property >
        <!-- 数据密码 -->
        <property name="hibernate.connection.password">
            123456
        </property>
    <!--     dialect  -->
    <property name="dialect">
        org.hibernate.dialect.SQLServerDialect
    </property>
    <!-- 是否将运行生成的SQL输出到日志调试 -->
    <property name="hibernate.show_sql">
        True
    </property>
    <property name="javax.persistence.validation.mode">none</property>
<!--     外连接数据库 -->
<!--     事务 -->
<!-- 映射文件配置,配置文件名必须包含其对应的全路径 -->
<mapping  resource="model/Tuser.hbm.xml"/>
    </session-factory>
</hibernate-configuration>

原文地址:https://www.cnblogs.com/lxh520/p/8061822.html