在Scala项目中使用带有SBT的jar

时间:2015-11-05 16:52:16

标签: java scala sbt mechanicalturk

我即将参与需要Mechanical Turk java API的Scala / SBT项目。 Mturk提供了如何使用Ant在Java中安装依赖项的说明。 我想我可以把准备好的jar(从Maven下载)放到/ lib中,这应该在我的Scala项目中工作,但是在编译时我会遇到依赖性错误。这是因为jar没有与org.apache.commons一起打包吗?

  

线程“main”中的异常java.lang.NoClassDefFoundError:org / apache / commons / httpclient / protocol / SecureProtocolSocketFactory

更新:

尝试将此依赖项添加到SBT。

libraryDependencies += "net.ettinsmoor" % "java-aws-mturk" % "1.6.2"

Error:Error while importing SBT project:
...
    at sbt.std.Transform$$anon$4.work(System.scala:63)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
    at sbt.Execute.work(Execute.scala:235)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
    at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
    at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
[error] sbt.ResolveException: unresolved dependency: org.apache.commons#not-yet-commons-ssl;0.3.7: not found
[error] unresolved dependency: apache-xerces#xercesImpl;2.9.1: not found
[error] unresolved dependency: apache-xerces#resolver;2.9.1: not found
[error] unresolved dependency: apache-xerces#xml-apis;2.9.1: not found
[error] Use 'last' for the full log.

See complete log in /Users/marcin/Library/Logs/IdeaIC14/sbt.last.log

1 个答案:

答案 0 :(得分:1)

您必须将MTurk依赖项添加到您的sbt构建文件(build.sbt)。像那样:

libraryDependencies += "org.clojars.zaxtax" % "java-aws-mturk" % "1.6.2"