【发布时间】:2018-04-21 02:29:52
【问题描述】:
我在播放框架中使用 Silhouette 库时遇到问题,我正在使用 guice 进行运行时依赖注入,创建接受 DelegableAuthInfoDAO 作为参数的 DelegableAuthInfoRepository 时出错,它说 DelegableAuthInfoDAO 未绑定到具体实例,即使我在configure方法中做了一个绑定,这是我启用模块时遇到的错误
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)
这是模块中完成的一些配置:
@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())
}
【问题讨论】:
标签: scala playframework-2.0 guice playframework-2.6 silhouette