object compress不是org.apache.commons包的成员

时间:2017-10-05 13:02:18

标签: scala sbt apache-commons

我一直在尝试使用apache commons。 但是,它失败并得到以下错误。 我不知道如何解决它。也许,需要在build.sbt中添加一些内容吗?

$ sbt
> clean
> compile
[error] hw.scala:3: object compress is not a member of package org.apache.commons
[error] import org.apache.commons.compress.utils.IOUtils
[error]                           ^
[error] hw.scala:24: not found: value IOUtils
[error]     val bytes = IOUtils.toByteArray(new FileInputStream(imgFile))
[error]                 ^
[error] two errors found
[error] (compile:compileIncremental) Compilation failed

hw.scala

import org.apache.commons.codec.binary.{ Base64 => ApacheBase64 }
import org.apache.commons.compress.utils.IOUtils

...

build.sbt

name := "hello"

version := "1.0"

scalaVersion := "2.11.8"

libraryDependencies ++= Seq(
  "commons-codec" % "commons-codec" % "1.10",
  "commons-io" % "commons-io" % "2.4"
)

1 个答案:

答案 0 :(得分:1)

在build.sbt中添加:

// https://mvnrepository.com/artifact/org.apache.commons/commons-compress
libraryDependencies += "org.apache.commons" % "commons-compress" % "1.14"

要在将来自行查找,请搜索https://mvnrepository.com/