Skip to content

Instantly share code, notes, and snippets.

@nemo83
Last active November 16, 2015 17:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nemo83/37e9deb76de51a9d9ce4 to your computer and use it in GitHub Desktop.
Save nemo83/37e9deb76de51a9d9ce4 to your computer and use it in GitHub Desktop.
Perform Dependency Injection of Beans of the same type identified by name
package services
import com.example.driver.RedisClient
import com.google.inject.Inject
import com.google.inject.name.Named
class MyRedisService @Inject()(@Named("myDbOne") redisClientOne: RedisClient, @Named("myDbTwo") redisClientTwo: RedisClient) {
def doSomething = {
redisClientOne.doSomething
redisClientTwo.doSomething
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment