未解决的依赖关系:SBT中的net.sourceforge.htmlunit

tmp*_*ies 1 sbt htmlunit

build.sbt的内容如下:

name := "hello-world"

version := "1.0"

scalaVersion := "2.10.3"

libraryDependencies += "net.sourceforge.htmlunit" %% "htmlunit" % "2.13"
Run Code Online (Sandbox Code Playgroud)

当我update在sbt控制台中执行时,它说:

[error] (*:update) sbt.ResolveException: unresolved dependency: net.sourceforge.htmlunit#htmlunit_2.10;2.13: not found
Run Code Online (Sandbox Code Playgroud)

我该怎么做让sbt找到这个库?

Vis*_*ohn 6

只需在依赖项中使用单个%而不是双%%精度.

libraryDependencies += "net.sourceforge.htmlunit" % "htmlunit" % "2.13"
Run Code Online (Sandbox Code Playgroud)

%%仅当jar的路径包含Scala版本时才需要,而Scala版本不是依赖项的情况.我想出了咨询mvnrepository - http://mvnrepository.com/artifact/net.sourceforge.htmlunit/htmlunit/2.13.只需将鼠标悬停在"下载(JAR)"链接上即可看到完整路径.

注意:默认情况下,sbt使用标准的Maven2存储库.如果您在默认仓库中找不到依赖的罐子,那么您需要添加这样的自定义解析器

resolvers += "custom_repo" at "url"
Run Code Online (Sandbox Code Playgroud)

对于此特定示例,由于htmlunit存在于默认仓库中,因此不需要解析器.