Starting Flyway No More Repeatedly

This commit is contained in:
JiaJu Zhuang
2023-07-29 21:30:30 +08:00
parent 23b69803ff
commit 97de0b5f0c
2 changed files with 3 additions and 2 deletions

View File

@@ -35,7 +35,7 @@ public class Application {
String currentVersion = ConfigUtils.getLocalVersion();
ConfigJson configJson = ConfigUtils.getConfig();
// Represents that the current version has been successfully launched
if (StringUtils.equals(currentVersion, configJson.getLatestStartupSuccessVersion())) {
if (StringUtils.isNotBlank(currentVersion) && StringUtils.equals(currentVersion, configJson.getLatestStartupSuccessVersion())) {
// Flyway doesn't need to start every time to increase startup speed
args = ArrayUtils.add(args, "--spring.flyway.enabled=false");
log.info("The current version {} has been successfully launched once and will no longer load Flyway.",

View File

@@ -23,7 +23,8 @@ public class AsyncContextRefreshedListener implements ApplicationListener<Contex
// Successfully set up startup
String currentVersion = ConfigUtils.getLocalVersion();
ConfigJson configJson = ConfigUtils.getConfig();
if (!StringUtils.equals(currentVersion, configJson.getLatestStartupSuccessVersion())) {
if (StringUtils.isNotBlank(currentVersion) && !StringUtils.equals(currentVersion,
configJson.getLatestStartupSuccessVersion())) {
configJson.setLatestStartupSuccessVersion(currentVersion);
ConfigUtils.setConfig(configJson);
}