How to solve FlyWay license problem in Spring Boot Application
Asked Answered
S

1

5

My Spring Boot application which uses FlyWay enterprise license does not start and says the following message:

Caused by: org.flywaydb.core.api.FlywayException: Missing license key. 
Ensure flyway.licenseKey is set to a valid Flyway license key ("FL01" followed by 512 hex chars)

The license is actually not missing. I've tried to set both as an env variable and in application.yml file with the name spring >> flyway >> licenseKey, but it is not reacting at all.

Any ideas where could the problem be hidden? The other env variables are considered by spring boot for database so this should not be the problem.

Stithy answered 10/2, 2019 at 14:47 Comment(0)
M
7

There is a good discussion of this on GitHub. According to that issue, a property-based version of this appears to be on the roadmap for Spring Boot 2.2.

Apparently for now you need to implement a FlywayConfigurationCustomizer (Untested):

@Configuration
public class FlywayConfiguration {
    @Bean
    public FlywayConfigurationCustomizer customizeLicense(
                 @Value("${my-app.flyway.license}") String license) {
        return new FlywayConfigurationCustomizer() {

            @Override
            public void customize(FluentConfiguration configuration) {
                configuration.licenseKey(license);
            }
        };
    }
}

I think that can probably be simplified to a lambda (also untested)...

@Configuration
public class FlywayConfiguration {
    @Bean
    public FlywayConfigurationCustomizer customizeLicense(
                 @Value("${my-app.flyway.license}") String license) {
        return configuration -> configuration.licenseKey(license);
    }
}
Meteorology answered 10/2, 2019 at 15:52 Comment(3)
Works like a charm, thank you very much for your answer. It is amazing how few lines of sentences from a professional saves a lot of time and money, sometimes the job of the other peopel :)Stithy
I’m glad it helped!Meteorology
Does any one know how to activate the license for Spring boot 3.2.4 and flyway 10 and above version ?Oleaster

© 2022 - 2025 — McMap. All rights reserved.