Skip to content

后端开发 基础数据初始化

李昌文 edited this page Nov 11, 2018 · 3 revisions

基础数据初始化

one-db-init是基于flyway来首次初始化数据的,也可用于以后更新数据库。

配置文件

在文件 one-db-init\src\main\resources\application.yml 中配置数据库等信息,具体配置请打开文件查看。

spring.datasource:
  url: jdbc:mysql://127.0.0.1:3306/one?useUnicode=true&characterEncoding=utf-8
  username: root
  password: one
  driver-class-name: com.mysql.jdbc.Driver

初始化数据

直接运行OneDbInitApplication.java启动one-db-init工程。

可以在控制台中看到类似如下信息,表示数据库已经初始化成功。

Creating Schema History table: `flyway`.`flyway_schema_history`
Current version of schema `flyway`: << Empty Schema >>
Migrating schema `flyway` to version 1 - init table
Migrating schema `flyway` to version 10 - sys config
Migrating schema `flyway` to version 11 - sys area
Migrating schema `flyway` to version 12 - sys dict
Migrating schema `flyway` to version 13 - sys message
Migrating schema `flyway` to version 14 - sys role
Migrating schema `flyway` to version 15 - sys user
Successfully applied 7 migrations to schema `flyway` (execution time 00:14.407s)