SQL(DDL)脚本的推荐位置是什么? [英] What's the recommended location for SQL (DDL) scripts?

查看:79
本文介绍了SQL(DDL)脚本的推荐位置是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Maven标准目录结构?

我敢打赌,几乎每个Web项目都使用一个DB和一些SQL脚本,这些脚本需要存储在某个地方,那么保存这些文件的最佳"地方应该是什么?

I bet almost every web project uses a DB and some kind of SQL scripts that need to be stored somewhere, so what would probably be the "best" place where to keep these files?

请告知.

推荐答案

我认为没有最佳实践.在我过去的项目中,我创建了一个单独的目录来存储此类SQL脚本.

I think there is no best practice for this. In my past project, I created a separate directory for storing such SQL script.

例如src/main/db.

默认情况下,它不会打包到最终的JAR中(在大多数情况下,这是首选方式),但它很方便,可以将其打包为程序集.您甚至可以通过添加相应的资源声明或使用maven build-helper插件将它们打包在主工件JAR中.

It won't be packaged to final JAR by default (which are the preferred way in most case), yet it is convenient enough to let it packaged in assembly. You can even package them in the main artifact JAR, by adding corresponding resource declaration or using maven build-helper plugin.

但是,所有这些都取决于您对该脚本的使用情况.我简单的经验法则"是,仅当它们确实是应用程序要加载的资源时,我才考虑将它们放在resources/中.

However, all depends on your usage on this script. My simple "rule of thumb" is that, I would consider putting them in resources/ only when they are really resources to be loaded by the application.

这篇关于SQL(DDL)脚本的推荐位置是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆