如何在项目中覆盖位于 jar 文件中的 Flyway .sql 迁移文件?

huangapple go评论60阅读模式
英文:

How to overwrite flyway .sql migration file within a jar from my project?

问题

我正在开发一个模块化的Java应用程序。

我的一些Flyway .SQL迁移文件包含在一个已安装的.jar文件中。

如何在我的项目内部覆盖其中一个.sql迁移文件,以便我的文件被用于执行迁移,而不是由jar提供的文件?

英文:

I am working on a Java application that is modular.

Some of my flyway .SQL migration files are within an installed .jar.

How can I overwrite one of those .sql migration file from within my project so mine get executed for the migration instead of the one provided by the jar?

答案1

得分: 1

首先,您可以从您想要更改的jar包中提取所有文件:

jar -xvf filename.jar

请注意:这将会生成大量的文件和文件夹。

接下来,您必须找到 .sql 文件,并且重要的是,记住确切的文件名。修改 SQL 然后执行:

jar uf jar-file input-file(s)

使用这个命令,如果文件存在,它会进行覆盖。您可以使用新文件来执行您的 .jar 文件!

我使用它来修改 Maven 的 jar 包中的 pom.xml 属性,它是有效的。我不清楚您的 .jar 文件是如何保存 .sql 文件的。

英文:

First, you can extract all files from the jar that you want to change:

jar -xvf filename.jar

Be careful: it will generate a lot of files and folders.

Next, you must find the .sql file and, important, memorize the exactly name. Modify the SQL and, next, execute:

jar uf jar-file input-file(s)

With this command, if the file exists, it will overwrite it. You can execute your .jar with your new file!

I use it with maven jars to modify pom.xml properties and it works. I don't know how your .jar save the .sql files.

huangapple
  • 本文由 发表于 2020年4月11日 13:43:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/61152613.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定