How to disable span in a specific spring profile?

Now I have a spring boot application that uses the MsSQL server. And we use the span 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 to write something in application.yaml

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

but the span begins anyway

+38
source share
4 answers

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

flyway.enabled -boot has the property to disable flyway if it needs flyway.enabled which defaults to true.

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

 flyway: enabled: false 

And if you specify a test profile in the general configuration, just add it to the root directory.

+50
source

For your information, for those who come here looking for this, the property name for Spring Boot 2.0 has been changed :

For application.properties format:

 spring.flyway.enabled=false 

For application.yml format:

 spring: flyway: enabled: false 

Update: to disable span in a specific profile, you can put this property in the properties file related to this profile. For example, if your profile is called "abc", you can put it in application-abc.properties . Check out Spring's documentation on profile properties to find out how to name files. This is usually the format application-{profileName}.properties .

+87
source

JIC official documentation with the current spring download 2.x: General application properties and look at the tag # FLYWAY, you will find many properties that can help you.

 spring.flyway.enabled=false # Whether to enable flyway. 
+1
source

Here is an example application.yaml It defines 2 profiles:
1. enable_flyway_profile - enables span
2. disable_flyway_profile - disables span

 spring: profiles: active: "enable_flyway_profile" flyway: enable: true .... --- spring: profiles: active: "disable_flyway_profile" flyway: enable: false .... 
-1
source

Source: https://habr.com/ru/post/1268405/


All Articles