spring boot使用flyway

spring boot integrated flyway

1. Add pom-dependent

    <plugin>
        <groupId>org.flywaydb</groupId>
        <artifactId>flyway-maven-plugin</artifactId>
        <executions>
            <!--当install时会执行migrate-->
            <execution>
                <phase>generate-sources</phase>
                <goals>
                    <goal>migrate</goal>
                </goals>
            </execution>
        </executions>
        <dependencies>
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>5.1.39</version>
            </dependency>
        </dependencies>
        <configuration>
            <driver>com.mysql.jdbc.Driver</driver>
            <url>jdbc:mysql://localhost:3306/first_boot</url>
            <user>root</user>
            <password>123456</password>
            <!--<schemas></schemas>-->
        </configuration>
 </plugin>

2. Add the resource in the folder db / migration
Here Insert Picture Description
3. Export sql database migration to the next file created above folder, and rename
V1_XX_XX_XX.sql, attention must be capitalized V1 of V
Here Insert Picture Description
4. Run mvn flyway: migrate to run sql

mvn flyway:migrate
Published 47 original articles · won praise 6 · views 2184

Guess you like

Origin blog.csdn.net/weixin_44467251/article/details/103647414