Reputation: 1418
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&useUnicode=true&characterEncoding=UTF-8&connectionCollation=utf8_unicode_ci&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?
Upvotes: 4
Views: 10720
Reputation: 1166
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
Upvotes: 5
Reputation: 1100
To read *.yml
properties from pom you should use https://github.com/aadnk/yaml-properties-plugin
Upvotes: 1
Reputation: 4231
My understanding is that if you are using Flyway with Spring Boot you do not use the flyway-maven plugin.
EDIT: Using Flyway CLI has a place when you need to work with the DB directly to make modifications to Flyway's schema table. An example would be to init
an existing DB or clean
a test project.
These are the current settings that can be performed out of the box by setting properties within the application.properties
for Flyway.
# FLYWAY (FlywayProperties)
flyway.check-location=false # check that migration scripts location exists
flyway.locations=classpath:db/migration # locations of migrations scripts
flyway.schemas= # schemas to update
flyway.init-version= 1 # version to start migration
flyway.init-sqls= # SQL statements to execute to initialize a connection immediately after obtaining it
flyway.sql-migration-prefix=V
flyway.sql-migration-suffix=.sql
flyway.enabled=true
flyway.url= # JDBC url if you want Flyway to create its own DataSource
flyway.user= # JDBC username if you want Flyway to create its own DataSource
flyway.password= # JDBC password if you want Flyway to create its own DataSource
YAML version:
flyway:
check-location: false
locations: classpath:db/migration
....
If you need further customization you may need to write a @Bean
to further customize how Flyway interacts with your application.
Upvotes: 3