对象压缩不是包 org.apache.commons 的成员

object compress is not a member of package org.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"
)

将此添加到您的 build.sbt 中:

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

以后要自己查找,请搜索https://mvnrepository.com/