繁体   English   中英

flyway.properties 文件不能作为 pom.xml 配置替代工作

[英]flyway.properties file not working as pom.xml configuration alternative

我需要设置 flyway 迁移,我不想将密码和用户名放在 pom.xml 中,我创建了 flyway.properties 文件,但它不起作用,我收到此错误

Failed to execute goal org.flywaydb:flyway-maven-plugin:6.5.1:clean (default-cli) on project entesting: org.flywaydb.core.api.FlywayException: Unable to connect to the database. Configure the url, user and password!

flyway.properties 文件与 pom.xml 位于同一目录中

flyway.user=sa
flyway.password=passwordForThis
flyway.url=jdbc:sqlserver://172.23.176.144;database=DB_Name
flyway.locations=filesystem:src/main/resources/db/migration
flyway.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver

pom.xml flyway插件配置:

        <plugin>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-maven-plugin</artifactId>
            <version>6.5.1</version>
            <configuration>
                <url>jdbc:sqlserver://172.23.176.144;database=DB_Name</url>
                <user>sa</user>
                <password>passwordForThis</password>
            </configuration>
        </plugin>

总而言之,我不想在 pom.xml(有效)中添加密码、用户名等,我希望它在 flyway.propeties 中。

除了直接将 Flyway 放入 maven pom.xml 之外,还可以通过多种方式配置 Flyway。 请参阅有关配置 maven 插件的文档

您显示的属性文件的内容类似于flyway.conf文件的内容。 Flyway 将搜索并自动加载<user-home>/flyway.conf配置文件(如果存在)。

也可以将 Flyway 指向一个或多个附加配置文件。 这是通过提供系统属性flyway.configFiles来实现的,如下所示:

mvn -Dflyway.configFiles=path/to/myAlternativeConfig.conf flyway:migrate

有关详细信息,请参阅https://flywaydb.org/documentation/maven/#config-files

也可以使用 Maven settings.xml文件来存储数据库用户和密码:

<settings>
   <servers>
       <server>
           <!-- By default Flyway will look for the server with the id 'flyway-db' -->
           <!-- This can be customized by configuring the 'serverId' property -->
           <id>flyway-db</id>
           <username>myUser</username>
           <password>mySecretPwd</password>
       </server>
   </servers>
</settings>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM