springmvc 初始化表结构,函数和存储过程的方法

在application.xml 中配置如下代码

    <jdbc:initialize-database data-source="dataSource" ignore-failures="NONE" enabled="${jdbc.initializedatabase}" >
        <jdbc:script encoding="utf-8" location="classpath:config/*.sql"/>
        <jdbc:script encoding="utf-8" location="classpath:config/*.fuc" separator="$$"/>
    </jdbc:initialize-database>

并在beans里新增

xmlns:jdbc="http://www.springframework.org/schema/jdbc"

xsi中新增

http://www.springframework.org/schema/jdbc
http://www.springframework.org/schema/jdbc/spring-jdbc-4.0.xsd

enabled ture 代表项目启动就开始初始化表,false代表关闭
dataSource 代表数据库配置的ID
separator 代表以某种字符结束,默认以分号(;)结束
函数范例:

DROP FUNCTION IF EXISTS `test`$$/*以$$结束*/
CREATE FUNCTION `test`    
END$$/*以$$结束*/

猜你喜欢

转载自blog.csdn.net/boenwan/article/details/73321520
今日推荐