简体   繁体   中英

Silhouette Unexpected exception playframework 2.6

I have a problem using Silhouette library in play framework,I am using guice for runtime dependency injection, there is an error when creating DelegableAuthInfoRepository which accepts a DelegableAuthInfoDAO as argument, it says DelegableAuthInfoDAO is not bound to a concrete instance even though I have done a binding in the configure method,here is the error I get when enabling the module

play.api.UnexpectedException: Unexpected exception[CreationException: Unable 
to create injector, see the following errors:

1) No implementation for 
com.mohiva.play.silhouette.persistence. 
daos.DelegableAuthInfoDAO<com.mohiva.pla
y.silhouette.api.util.PasswordInfo> was bound.
while locating 


com.mohiva.play.silhouette.persistence.daos 
.DelegableAuthInfoDAO<com.mohiva.play
.silhouette.api.util.PasswordInfo>
for the 1st parameter of 
modules.authModule.provideAuthInfoRepository(authModule.scala:112)
at modules.authModule.provideAuthInfoRepository(authModule.scala:112) (via 
modules: com.google.inject.util.Modules$OverrideModule -> 
modules.authModule)

Here is some of the configuration done in the module:

@Provides
def provideAuthInfoRepository(passwordInfoDAO: DelegableAuthInfoDAO[PasswordInfo]): AuthInfoRepository = {
  new DelegableAuthInfoRepository(passwordInfoDAO)
}

override def configure() = {
  bind(classOf[UserDAO]).asEagerSingleton()
  bind(classOf[IdentityService[User]]).to(classOf[UserService])
  bind(classOf[CacheLayer]).to(classOf[PlayCacheLayer])

  bind(classOf[PasswordHasher]).toInstance(new BCryptPasswordHasher())
  bind(classOf[EventBus]).toInstance(new EventBus)
  bind(classOf[DelegableAuthInfoDAO[PasswordInfo]]).toInstance(new InMemoryAuthInfoDAO[PasswordInfo]())
  bind(classOf[IDGenerator]).toInstance(new SecureRandomIDGenerator())
  bind(classOf[FingerprintGenerator]).toInstance(new DefaultFingerprintGenerator(false))
  bind(classOf[Clock]).toInstance(Clock())
}

这有效:

bind(new TypeLiteral[DelegableAuthInfoDAO[PasswordInfo]]{}).toInstance(new InMemoryAuthInfoDAO[PasswordInfo])

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