更改flyway-maven-plugin的默认脚本目录

时间:2015-10-27 16:42:07

标签: maven flyway

如何更改以下flyway-maven-plugin配置,以便我可以在src/main/database而不是src/main/resources/db/migration中删除我的脚本?

migrate mojo source code似乎表示默认值为db/migration,但是src/main/resources/呢?

            <plugin>
                <groupId>org.flywaydb</groupId>
                <artifactId>flyway-maven-plugin</artifactId>
                <version>3.2.1</version>
                <configuration>
                    <url>jdbc:h2:file:target/tmp</url>
                    <user>sa</user>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>com.h2database</groupId>
                        <artifactId>h2</artifactId>
                        <version>1.4.190</version>
                    </dependency>
                </dependencies>
            </plugin>

1 个答案:

答案 0 :(得分:5)

locations属性设置为所需的目录。前缀为filesystem:,如果它位于文件系统而不是类路径上:http://flywaydb.org/documentation/maven/migrate.html

对于您的用例,请使用以下内容:

            <plugin>
                <groupId>org.flywaydb</groupId>
                <artifactId>flyway-maven-plugin</artifactId>
                <version>3.2.1</version>
                <configuration>
                    <url>jdbc:h2:file:target/tmp</url>
                    <user>sa</user>
                    <locations>
                        <location>filesystem:src/main/database</location>
                    </locations>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>com.h2database</groupId>
                        <artifactId>h2</artifactId>
                        <version>1.4.190</version>
                    </dependency>
                </dependencies>
            </plugin>