Spring boot 每次我在WAR和IDE运行模式之间切换运行模式时,带spring boot的Flyway都会覆盖整个DB

Spring boot 每次我在WAR和IDE运行模式之间切换运行模式时,带spring boot的Flyway都会覆盖整个DB,spring-boot,flyway,Spring Boot,Flyway,在将flyway DB迁移与spring boot应用程序集成时,我面临着非常奇怪的问题 当我使用命令行从可执行WAR运行应用程序时,它会在应用程序启动时创建新的DB。 现在,如果我将应用程序运行模式切换到IDE(即从STS运行),它将再次从我的db/migration文件夹中激发所有脚本。每次在这两种运行模式之间切换时,我都可以看到列上的installed\u时间发生变化。我已尝试启用baselineOnMigrate属性,但没有任何效果。 你认为这与spring boot嵌入式tomcat有

在将flyway DB迁移与spring boot应用程序集成时,我面临着非常奇怪的问题

当我使用命令行从可执行WAR运行应用程序时,它会在应用程序启动时创建新的DB。 现在,如果我将应用程序运行模式切换到IDE(即从STS运行),它将再次从我的
db/migration
文件夹中激发所有脚本。每次在这两种运行模式之间切换时,我都可以看到列上的
installed\u时间发生变化。我已尝试启用
baselineOnMigrate
属性,但没有任何效果。 你认为这与spring boot嵌入式tomcat有关吗?因为在两次运行时,它都会创建一个嵌入的tomcat

请在下面找到我的spring boot application.properties:

mssql.dbname=issueDB
mssql.password=password
mssql.dbserver=localhost
mssql.port=1501

spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.datasource.url=jdbc:sqlserver://${mssql.dbserver}:${mssql.port};databaseName=${mssql.dbname}
spring.datasource.username=user
spring.datasource.password=${mssql.password}

spring.flyway.baselineOnMigrate=true
spring.flyway.locations=classpath:db/migration/testissue
spring.flyway.out-of-order=true
spring.flyway.baseline-version=1.3
spring.flyway.placeholder-prefix=$
spring.flyway.placeholder-suffix=$
spring.flyway.mixed=true
spring.flyway.cleanOnValidationError=true

我想,这可能是由这个属性引起的
spring.flyway.cleanOnValidationError=true
。根据报告:

发生验证错误时是否自动调用clean

这完全是为了方便开发。即使很难,我们强烈建议在将迁移脚本签入SCM并运行后不要更改它们,这提供了一种平稳处理这种情况的方法。数据库将被自动清除,确保下一次迁移将使您恢复到已签入SCM的状态


如果您在同一数据库上以不同方式运行应用程序,可能会遇到一些验证问题,flyway只需清理数据库并用当前脚本状态覆盖它。

是的,这就是原因,感谢您的支持。我发现,当我试图在IDE中运行和从WAR运行时,校验和不匹配会发生。现在gradle bootWar目标在这里引起了一些事情。你对此有什么想法吗?