简体   繁体   中英

Import Java library to Scala sbt project

I'm trying to use import guava library in SBT project (play framework), but can't compile my code

import com.google.common.net.InternetDomainName

class MyClass(link: String) {
  private val domains = {
    val host = new URL(link).getHost
    val domainName = InternetDomainName.from(host)
    domainName.topPrivateDomain().name()
  }
}

I get compilation error

object google is not a member of package com

Can anyone explain, what is the problem?

Have you added the guava library as a library dependency to your build.sbt file? You can find that file in the project's root directory. There you can add the dependency to the guava library:

libraryDependencies ++= Seq(
  "com.google.guava" % "guava" % "17.0",
  // other dependencies separated by commas
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM