简体   繁体   English

如何将JDBC驱动程序作为系统依赖项放置在SBT项目中以开发模式进行Scala / Play项目

[英]How to place JDBC Drivers as System Dependencies in SBT Projects Scala/Play Projects in Dev Mode

I have a bunch of dependencies, such as JDBC Drivers, from vendors like Oracle, and Microsoft, which are not on a Public Artifact Repository. 我有许多依赖项,例如来自Oracle和Microsoft等供应商的JDBC驱动程序,它们不在公共工件库中。

Everytime I want those dependencies to be available while running my Play Application in Dev Mode , I have to put those jars in lib folder(within the play project) 每次我希望在开发模式下运行我的Play应用程序时可以使用这些依赖项时,我必须将这些jar放在lib文件夹中(在play项目中)

Those drivers are supposed to vary from Customer to Customer, and in some phases of the project we need a Oracle one, some other phase, 2 drivers. 这些驱动程序应该因客户而异,在项目的某些阶段我们需要Oracle,其他一些阶段,2个驱动程序。

Another point is that, we have multiple Play Applications that we use those drivers, and have to manually place them within the lib folder 另一点是,我们有多个Play应用程序,我们使用这些驱动程序,并且必须手动将它们放在lib文件夹中

How can I avoid this?? 我怎么能避免这个?

I need those jars in the classpath for when I am saying from the command line: 当我从命令行说出来时,我需要在类路径中使用这些jar:

sbt run "play-project" -Dhttp.port=9001

Maybe there is some play parameter that I can also pass an additional classpath. 也许有一些播放参数,我也可以传递一个额外的类路径。

I am using Play 2.4 and Scala 2.11.7 我使用的是Play 2.4和Scala 2.11.7

I think you have two solutions: 我认为你有两个解决方案:

  1. Add your specifics jar files in a common folder and reference that one from your build file. 将您的特定jar文件添加到公共文件夹中,并从构建文件中引用该文件。 You should add some environment properties or some configurable way to allow other people from your team to configure the jars location. 您应该添加一些环境属性或一些可配置的方式,以允许团队中的其他人配置jar位置。

  2. Create a private maven or ivy repository that contains the specific jars. 创建包含特定jar的私有maven或ivy存储库。 It could be as simple as a http server with the files and the correct directory structure. 它可以像具有文件和正确目录结构的http服务器一样简单。 This allows you to internally distribute the jar file without having people to configure specific folders on their machines. 这允许您在内部分发jar文件,而无需人员在其计算机上配置特定文件夹。

For the first solution, from SBT documentation , you should just add those jars in your unmanaged classpath, with in your build.sbt file a line like: 对于第一个解决方案,从SBT文档中 ,您应该只在非托管类路径中添加这些jar,在build.sbt文件中添加如下行:

unmanagedJars in Compile := (file("/my_common_path") ** "*.jar").classpath

For the second solution, just have a look at sbt's resolver documentation 对于第二个解决方案,只需看看sbt的解析器文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM