如何将外部 jar 文件包含到带有包的 jar 中? [英] How to include an external jar file into the jar with package?

查看:55
本文介绍了如何将外部 jar 文件包含到带有包的 jar 中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目依赖于外部 jar.我创建了一个目录 lib 并将 jar 文件复制到其中.这是我的build.sbt:

My project has dependency on an external jar. I have created a directory lib and have copied the jar file into it. This is my build.sbt:

name := "approxstrmatch"

version := "1.0"

scalaVersion := "2.10.4"

unmanagedJars in Compile += file("lib/secondstring-20140729.jar")

libraryDependencies+="org.apache.spark"%%"spark-core"%"1.0.0"

resolvers += "AkkaRepository" at "http://repo.akka.io/releases/"

当我运行 cleanpackage 时,外部 jar 文件没有包含在生成的 jar 文件中.为什么?

When I run clean and package, the external jar file does not get included in the generated jar file. Why?

这是项目布局:

project/build.sbt
lib/
src/.....

推荐答案

试试这个

libraryDependencies += "com.acme.common" % "commonclass" % "1.0" from "file:///Users/bwong/git/perf-tools/commonclass/target/scala-2.11/commonclass_2.11-1.0.jar"

我将公共类项目sbt 打包",然后在依赖项目的 build.sbt 中添加该库依赖项.

I "sbt package" the common classproject and then just add that library dependency in my build.sbt in the dependent projects.

感谢 http://flummox-engineering.blogspot.com/2014/06/sbt-use-jar-file-for-librarydependencies.html 用于此 hack.

Thanks to http://flummox-engineering.blogspot.com/2014/06/sbt-use-jar-file-for-librarydependencies.html for this hack.

这篇关于如何将外部 jar 文件包含到带有包的 jar 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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