您的位置:首页 > 房产 > 家装 > bug: 配置flyway.locations多个脚本位置不生效

bug: 配置flyway.locations多个脚本位置不生效

2024/10/5 18:28:45 来源:https://blog.csdn.net/qq_21880261/article/details/141033012  浏览:    关键词:bug: 配置flyway.locations多个脚本位置不生效

文章目录

  • 业务场景
  • 场景一
  • 场景二

业务场景

随着项目版本迭代,数据库结构也会变动。如果一个项目引用其他项目的jar包,并且需要执行对应jar包的flyway脚本,就需要配置flyway.locations

场景一

正常情况下,在一个项目中可以在yml文件中指定多个flyway脚本的地址,比如:可以正常执行

spring:datasource:type: com.zaxxer.hikari.HikariDataSourceurl: jdbc:postgresql://192.168.x.xx:5432/coreusername: xxxpassword: xxxxxxxhikari:poolName: Hikariauto-commit: falseflyway:enabled: trueschemas: publicencoding: UTF-8locations: - classpath:db/migration/db1- classpath:db/migration/db2

在这里插入图片描述

场景二

但是如果该模块还引用了其他模块,该模块也有flyway需要执行,新增下述配置,但file/db/migration文件夹下的脚本不会生效

</dependencies><dependency><groupId>com.xx.xx</groupId><artifactId>infra-xx-xx</artifactId><version>${project.version}</version></dependency>
</dependencies>flyway:locations:- classpath:db/migration/db1- classpath:db/migration/db2- classpath:file/db/migration

解决方案
该配置文件必须配置在依赖模块的yml文件中
在这里插入图片描述

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com