简体   繁体   English

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

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

I need to set flyway migration and I don't want to put password and username in pom.xml, I created flyway.properties file, but it's not working, I'm getting this error我需要设置 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 file is in same directory as pom.xml 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 config: 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>

To summarize I don't want to add password, username etc. in pom.xml(that works), I want it to be in flyway.propeties.总而言之,我不想在 pom.xml(有效)中添加密码、用户名等,我希望它在 flyway.propeties 中。

Flyway can be configured in a number of ways beyond directly putting it into the maven pom.xml.除了直接将 Flyway 放入 maven pom.xml 之外,还可以通过多种方式配置 Flyway。 See documentation on configuring the maven plugin请参阅有关配置 maven 插件的文档

The contents of the properties file you showed looks like the contents of a flyway.conf file.您显示的属性文件的内容类似于flyway.conf文件的内容。 Flyway will search for and automatically load the <user-home>/flyway.conf config file if present. Flyway 将搜索并自动加载<user-home>/flyway.conf配置文件(如果存在)。

It is also possible to point Flyway at one or more additional config files.也可以将 Flyway 指向一个或多个附加配置文件。 This is achieved by supplying the System property flyway.configFiles as follows:这是通过提供系统属性flyway.configFiles来实现的,如下所示:

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

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

Alternatively for storing the database user and password, Maven settings.xml files can also be used:也可以使用 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