Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to solve FlyWay license problem in Spring Boot Application

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.

like image 658
X-HuMan Avatar asked Feb 10 '19 14:02

X-HuMan


1 Answers

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);
    }
}
like image 62
Todd Avatar answered Sep 29 '22 19:09

Todd