How to disable flyway in a certain spring profile?

gstackoverflow :

Now I have a spring-boot app which uses MsSQL server. And we use flyway for migrations.

I want to add an additional profile for tests. I want to generate tables from entity classes instead of using flyway.

I tried smth to write like this in application.yaml

spring:
  profiles: test
  jpa:
      generate-ddl: true
      hibernate:
  datasource:
    url: jdbc:h2:mem:test_db;MODE=MSSQLServer
    username: sa
    password:

but flyway starts anyway

Stanislav :

This answer works with Spring Boot 1.X version. If you are looking for answer for Spring Boot 2.X, you should see the below answer.

There is a property available for spring-boot to disable flyway if it's needed flyway.enabled which is true by default.

You can have a profile specific configuration, in your case it should be named as application-test.yml. This configuration can disable flyway if profile is active. You just have to declare it as follows:

flyway:
  enabled: false

And if you specify test profile in common configuration, just add it to it's root.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=424502&siteId=1