如何使用 Maven 处理多个数据库架构创建脚本?

发布于 2024-09-26 00:32:55 字数 480 浏览 1 评论 0原文

我正在开发一个应用程序,支持多种数据库,包括 SQL*Server 2008、Oracle 10G、Oracle 11G、MYSQL 5 等。在 Maven 中我已经做了三件事:

1)每个数据库都有一个配置文件,以便系统可以在构建过程中使用它进行集成测试。

2)Maven调用hibernate3插件使用hbm2ddl自动生成schema脚本。

3) 设置 Hudson 矩阵构建,以便自动针对每个数据库运行集成测试。

我注意到(毫不奇怪)hbm2ddl 创建的脚本根据数据库方言的不同而有所不同。

然而,当为客户打包系统时,我们必须手动进入各种 Hudson 构建并从那里提取数据库特定的脚本。这是一个乏味的过程,我相信这会在最糟糕的时刻困扰我们!

无论如何,我们是否可以让 Maven 自动生成然后收集所有这些数据库脚本,以便将它们与我们发送给客户的 WAR 文件一起打包?我正在考虑使用 Maven 程序集插件来将其全部压缩,但我不确定!

I have an application in development that supports several databases including SQL*Server 2008, Oracle 10G, Oracle 11G, MYSQL 5, etc. Already within Maven I have done three things:

1) There is a profile for each database so that the system can use it for integration testing during the build.

2) Maven invokes the hibernate3 plugin to automatically generate a schema script using hbm2ddl.

3) A Hudson matrix build is set up so that integration tests are run against every database automatically.

I have noticed (with no surprise) that the script created by hbm2ddl is different depending on the database dialect.

However, when packaging the system for customers we have to manually go into the various Hudson builds and pluck the database specific scripts from there. A tedious process that I am sure will bite us at the worst possible moment!!

Is there anyway that we can have Maven automatically generate and then gather up all these database scripts so that they can be packaged along side the WAR file we ship to customers? I was thinking of the Maven assembly plugin to zip it all up, but am not sure!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

回忆那么伤 2024-10-03 00:32:55

我们是否可以让 Maven 自动生成然后收集所有这些数据库脚本,以便将它们与我们发送给客户的 WAR 文件一起打包?
我正在考虑使用 Maven 程序集插件来将其全部压缩,但我不确定!

问题是,脚本是为每个配置文件运行生成的(至少这是我的理解),除非您将它们打包在某种不同的工件(可能是程序集)中并在每次运行时安装/部署它们,否则您不会能够在后续步骤中使用 Maven 获取它们。

另一种方法是使用一个模块来多次执行定义的 hbm2ddl 目标。但我担心这会破坏整个个人资料的内容。

或者您可以使用 M2 额外步骤插件依赖 Hudson 并向您的 Maven 构建添加一些构建后步骤(不确定这是否有帮助)。

Is there anyway that we can have Maven automatically generate and then gather up all these database scripts so that they can be packaged along side the WAR file we ship to customers?
I was thinking of the Maven assembly plugin to zip it all up, but am not sure!

The problem is that the scripts are generated for each profile run (at least this is my understanding) and unless you package them in some kind of distinct artifacts (could be assemblies) and install/deploy them at each run, you won't be able to grab them in a subsequent step with Maven.

The alternative would be to have a module with several executions of the hbm2ddl goal defined. But I'm afraid this will defeat the whole profile stuff.

Or you could maybe use the M2 Extra Steps Plugin to rely on Hudson and add some post-build steps to your Maven builds (not sure if this can help).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文