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

来源:互联网 发布:全基因组数据分析 编辑:程序博客网 时间:2024/05/28 15:53

在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/jdbchttp://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$$/*以$$结束*/
原创粉丝点击