Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flyway-maven-plugin how to read the settings from spring boot application.yml

In my Spring Boot project I want to use flyway-maven-plugin. My pom:

        <plugin>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-maven-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <url>jdbc:mysql://localhost:3306/my_database?autoReconnect=true&amp;useUnicode=true&amp;characterEncoding=UTF-8&amp;connectionCollation=utf8_unicode_ci&amp;characterSetResults=UTF-8</url>
                <user>root</user>
                <password>${spring.datasource.password}</password>
            </configuration>
        </plugin>

And here is my application.yml

spring:
  profiles.active: default
---
spring:
  profiles: default
spring.datasource:
  password: root

As I understood to use mvn flyway:info I need some plugin which will read my application.yml. Or maybe there is another way?

like image 616
PaintedRed Avatar asked Oct 25 '25 18:10

PaintedRed


1 Answers

I have the following in my src/main/resources/application.properties

flyway.url=jdbc:sqlserver://localhost:1433
flyway.user=james_hetfield
flyway.password=MetaLLic@

spring.datasource.url=${flyway.url}
spring.datasource.user=${flyway.user}
spring.datasource.password=${flyway.password}

And then I run the migrations from the command-line as follows

mvn -Dflyway.configFiles=src/main/resources/application.properties flyway:migrate
like image 197
pards Avatar answered Oct 27 '25 06:10

pards