【发布时间】:2021-12-26 11:51:21
【问题描述】:
我在使用 Akka Play 测试时遇到问题。我有这门课:
class Setvice @Inject() (
@NamedCache("token-cache") tokenCache: AsyncCacheApi
)
并在测试中使用此注射器:
private val cache: MockCaffeineCache = new CaffeineCacheApi(new NamedCaffeineCache("token-cache", new MockCaffeineCache)) // named cache not helping here
val application: Injector = new GuiceInjectorBuilder()
{some bindings here}
.bindings(bind[AsyncCacheApi].qualifiedWith("token-cache").to(cache))
据我所知,qualifiedWith 是另一回事,所以在这里也无济于事。
错误:
[info] - should return search result *** FAILED ***
[info] com.google.inject.ConfigurationException: Guice configuration errors:
[info]
[info] 1) No implementation for play.api.cache.AsyncCacheApi annotated with @play.cache.NamedCache(value="token-cache") was bound.
[info] Did you mean?
[info] * play.api.cache.AsyncCacheApi annotated with @com.google.inject.name.Named(value="token-cache")
我如何命名我的测试缓存以便注入传递?
【问题讨论】:
标签: scala playframework