zoukankan      html  css  js  c++  java
  • spring和hibernate整合时无法自动建表

     在使用spring整合hibernate时候代码如下:

    <property name="dataSource" ref="dataSource" />
                <!-- 配置hibernate的属性 -->
                <property name="hibernateProperties">
                    <props>
                        <prop key="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</prop>
                        <!--showsql-->
                        <prop key="hibernate.show_sql">true</prop>
                        <!--格式化sql代码-->
                        <prop key="hibernate.format_sql">true</prop>
                        <!--更新表结构-->
                        <prop key="hbm2ddl.auto">update</prop>
                    </props>
                </property>

    在spring配置文件中,并不识别“hbm2ddl.auto”项,所以配置没起到作用,使用“hibernate.hbm2ddl.auto”。

    <!-- 配置hibernate的属性 -->
                <property name="hibernateProperties">
                    <props>
                        <prop key="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</prop>
                        <!--showsql-->
                        <prop key="hibernate.show_sql">true</prop>
                        <!--格式化sql代码-->
                        <prop key="hibernate.format_sql">true</prop>
                        <!--更新表结构-->
                        <prop key="hibernate.hbm2ddl.auto">update</prop>
                    </props>
                </property>

     hibernate的前缀可有可无,但是在整合期间,最好都加上hibernate前缀!减少不必要的时间去浪费在配置文件上!

  • 相关阅读:
    Linux--shell三剑客<sed>--07
    Linux--shell交互输入与循环语句--06
    Linux--shel分支语句--05
    Linux--shell grep与正则表达式--04
    Linux--shell编程原理--03
    Linux--shell重定向与文件处理命令--02
    Linux--shell的基本特性--01
    Docker数据卷
    Docker容器
    Docker的安装
  • 原文地址:https://www.cnblogs.com/wdnnccey/p/5967052.html
Copyright © 2011-2022 走看看