LiquiBaseを--- SpringBoot + Mavenの+ LiquiBaseを

SpringBoot + Mavenの+ LiquiBaseを

設定ファイル

スプリング:
LiquiBaseを:
変更ログ:クラスパス:CONF / LiquiBaseを/ master.xml
有効:真
ドロップ最初:偽
コンテキスト:DEV、PROD
1
2
3
4
5
6
代码中

輸入liquibase.integration.spring.SpringLiquibase;
輸入org.springframework.beans.factory.annotation.Value。
輸入org.springframework.context.annotation.Bean。
輸入org.springframework.context.annotation.Configuration。

インポートするjavax.sql.DataSource;

@Configuration
パブリッククラスLiquibaseConfig {

@value( "{spring.liquibase.enabled} $")
プライベートブール可能。

@value( "$ {spring.liquibase.drop-最初}")
プライベートブールdeopFirst。

@value( "$ {spring.liquibase.contexts}")
プライベート文字列コンテキスト。

@Bean(名= "LiquiBaseを")
パブリックSpringLiquibase springLiquibase(データソースデータソース){

SpringLiquibase springLiquibase =新しいSpringLiquibase();

springLiquibase.setDataSource(データソース)。
springLiquibase.setChangeLog( "クラスパス:/conf/liquibase/master.xml");
springLiquibase.setShouldRun(イネーブル)。
springLiquibase.setDropFirst(deopFirst)。
springLiquibase.setContexts(コンテキスト)。
springLiquibaseを返します。
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
master.xml

<?xml version = "1.0"エンコード= "UTF-8"?>
<databaseChangeLog
のxmlns = "http://www.liquibase.org/xml/ns/dbchangelog"
のxmlnsを:XSI = "のhttp://www.w3 .ORG / 2001 / XMLスキーマ・インスタンス"
のxsi:schemaLocationの=" http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd 「>

<プロパティ名= "今"値= "今()" DBMS = "H2" />
<プロパティ名= "今"値= "今()" DBMS = "MySQLの" />

<プロパティ名= "floatType"値= "するfloat4" DBMS = "PostgreSQLの、H2" />
<プロパティ名= "floatType"値= "フロート" DBMS = "のMySQLは、Oracle、MSSQL、mariadb" />

<relativeToChangelogFile = "偽の" / =インクルードファイル"CONF / LiquiBaseを/変更履歴/ 20190626reportdata_addcloumn.xml CLASSPATH"を含む>
</ databaseChangeLog>
後続のファイルに行を追加していき、添加
。1
2
3
4
5
6
7
8
9
10
11
12である
13れます
14
15
20190626reportdata_addcloumn.xml

<?xml version = "1.0"エンコード= "UTF-8"?>
<databaseChangeLog
のxmlns = "http://www.liquibase.org/xml/ns/dbchangelog"
のxmlns:EXT = "のhttp://www.liquibase .ORG / XML / NS / dbchangelog-EXT "
のxmlns:XSI = "http://www.w3.org/2001/XMLSchema-instance"
のxsi:schemaLocationの=" http://www.liquibase.org/xml/ns / dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/ XML / NS / dbchangelog / dbchangelog-ext.xsd ">

<プロパティ名= "自動インクリメント" 値= "true" を/>

<チェンジID = "20190626reportdata_addcloumn"著者= "zzh">
<AddColumn関数tableNameの= "report_data">
<列名= "ステータス"タイプ= "int型"発言= "状态"> </コラム>
</ AddColumn関数>
<AddColumn関数tableNameの= "report_data">
<カラム名= "create_user_id"タイプ= "INT"発言= "创建人ID"> </列>
</ AddColumn関数>
<AddColumn関数tableNameの= "report_data">
<カラム名= "check_user_id"タイプ= "INT"発言= "确认人ID"> </列>
</ AddColumn関数>
<AddColumn関数tableNameの= "report_data">
<カラム名= "CHECK_TIME"タイプ=」日時」発言= "确认时间"> </コラム>
</ AddColumn関数>
</チェンジ>
</ databaseChangeLog>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

---------------------

おすすめ

転載: www.cnblogs.com/liyanyan665/p/11183019.html