美文网首页
HAP_数据库数据初始化

HAP_数据库数据初始化

作者: 灯下驼贼 | 来源:发表于2018-08-02 19:19 被阅读0次
    image.png

    数据表如下:


    image.png image.png
    package wht.core.db
    
    import com.hand.hap.db.excel.ExcelDataLoader
    import com.hand.hap.liquibase.MigrationHelper
    
    def mhi = MigrationHelper.getInstance()
    dbType = MigrationHelper.getInstance().dbType()
    
    databaseChangeLog(logicalFilePath:"wht/core/db/2018-08-01-03-init-data.groovy"){
    
    
        changeSet(author: "ora_20796", id: "20180801-ora-20796csz-3") {
                //sqlFile(path: MigrationHelper.getInstance().dataPath("com/hand/hap/db/data/"+dbType+"/demo.sql"), encoding: "UTF-8")
        }
        //Milestone , excel data, runAlways=true
        changeSet(author: "ora_20796", id: "20180801-ora-20796csz-3", runAlways:"true"){
            customChange(class:ExcelDataLoader.class.name){
                param(name:"filePath",value:MigrationHelper.getInstance().dataPath("wht/core/db/data/2018-08-01-init-data.xlsx"))
            }
        }
    }
    
    

    然后打包

    mvn clean instrall
    

    初始化数据:

    mvn process-resources -D skipLiquibaseRun=false -D db.driver=com.mysql.jdbc.Driver -D db.url=jdbc:[mysql://localhost:3306/wht_dev](mysql://localhost:3306/wht_dev) -D db.user=root -D db.password=root -D db.skipUpdateTables="sys_config,sys_user"
    
    

    相关文章

      网友评论

          本文标题:HAP_数据库数据初始化

          本文链接:https://www.haomeiwen.com/subject/oqclvftx.html