Flyway中sql脚本修改导致的错误

  Flyway是一个简单开源数据库版本控制器(约定大于配置),主要提供migrate、clean、info、validate、baseline、repair等命令(Flyway java基本知识:https://blog.csdn.net/tanghin/article/details/51264795)。

  使用该工具,配置好数据库脚本,在项目运行的时候即可将数据库脚本执行到数据库中,同时会在数据库表schema_version中增加相应的记录(若第一次执行,则会创建该表)。

  今天重新导入了项目,在运行项目的时候报错: org.springframework.beans.factory.BeanCreationException: Errorcreating bean with name 'flyway' defined in URL[file:/E:/gerp/war/target/gerp/WEB-INF/classes/spring/spring-jdbc.xml]:Invocation of init method failed; nested exception isorg.flywaydb.core.api.FlywayException: Validate failed: Detected appliedmigration not resolved locally: 18.616之类的。

  通过查找资料(http://blog.didispace.com/spring-boot-flyway-db-version/)发现,Flyway执行脚本的时候会检查脚本是否有改动,并对其进行校验。若改动,则会校验错误,报错。

  后尝试把数据库表中的schema_version删除,但虽然能够执行脚本,但若存在一些不能重复操作的sql(如:建表语句),依然会报错。

  特此,记录一下。

你可能感兴趣的:(java)