codingwell / scala-guice

Scala extensions for Google Guice
Apache License 2.0
341 stars 44 forks source link

Type named is not a member of object com.google.inject.name.Names #63

Closed ghost closed 6 years ago

ghost commented 7 years ago

I have the following repo on GitHub which uses this library for DI of a very simple Scala app.

If you clone it an run ./gradlew run you'll see that its complaining about my use of @Names.named when specifying parameters to inject, specifically right here:

class DefaultListener @Inject() (@Names.named("username") val username : String) extends ActionListener with InputTypes {
  override def onAction(name: String, isPressed: Boolean, tpf: Float): Unit = {
    println(s"I am responding to something important for ${username}!")
  }
}

The specific exception states:

"type named is not a member of object com.google.inject.name.Names"

However I believe I've followed your documentation precisely. Can anyone spot where I'm going awry? Thanks in advance!

bfkelsey commented 7 years ago

It looks like you should just be using @Named. https://github.com/codingwell/scala-guice/blob/54492a989e48599d34223a14832059f7955605b7/src/test/scala/net/codingwell/scalaguice/ClassesForTesting.scala#L72