X-H*_*Man 4 java license-key flyway spring-boot
使用FlyWay企业许可证的我的Spring Boot应用程序无法启动,并显示以下消息:
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)
Run Code Online (Sandbox Code Playgroud)
许可证实际上并没有丢失。我试图将既设置为env变量,又设置为application.yml文件,名称为spring >> flyway >> licenseKey,但它根本没有反应。
有什么想法可以隐藏问题吗?Spring引导会考虑使用其他env变量作为数据库,因此这不是问题。
在GitHub上对此进行了很好的讨论。根据该问题,Spring Boot 2.2的路线图似乎是基于属性的版本。
显然,现在您需要实现FlywayConfigurationCustomizer(未经测试):
@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);
}
};
}
}
Run Code Online (Sandbox Code Playgroud)
我认为可以将其简化为lambda(也未经测试)...
@Configuration
public class FlywayConfiguration {
@Bean
public FlywayConfigurationCustomizer customizeLicense(
@Value("${my-app.flyway.license}") String license) {
return configuration -> configuration.licenseKey(license);
}
}
Run Code Online (Sandbox Code Playgroud)