[英]MacWire: Found multiple values of type
I'm using MacWire DI framework and I'm geting this error. 我正在使用MacWire DI框架,但出现此错误。
Found multiple values of type [play.api.mvc.DefaultActionBuilder]: [List(defaultActionBuilder, Action)]
[error] override lazy val controllerComponents: DefaultControllerComponents = wire[DefaultControllerComponents]
My applicatopn Loader is this: 我的应用程序加载器是这样的:
class AppApplicationLoader extends ApplicationLoader {
def load(context: Context) = {
LoggerConfigurator(context.environment.classLoader).foreach { cfg =>
cfg.configure(context.environment)
}
new AppComponents(context).application
}
}
class AppComponents(context: Context) extends
BuiltInComponentsFromContext(context) with AhcWSComponents
with AssetsComponents with HttpFiltersComponents
with EvolutionsComponents with DBComponents with HikariCPComponents with EhCacheComponents {
override lazy val controllerComponents: DefaultControllerComponents = wire[DefaultControllerComponents]
I've been getting some other errors similar after small modifications of the code. 在对代码进行少量修改之后,我得到了其他一些类似的错误。 How can I follow DI dependencies to track down these errors? 如何遵循DI依赖关系来跟踪这些错误?
Just encountered this myself, it appears to be due to this commit, which was included as a backport in Play 2.6.3: 我本人刚遇到此问题,似乎是由于此提交,在Play 2.6.3中作为反向端口包括在内:
https://github.com/playframework/playframework/pull/7676/files/809cd1e880b01d45e95d41e65f20bfa984d1e122#r138400765 https://github.com/playframework/playframework/pull/7676/files/809cd1e880b01d45e95d41e65f20bfa984d1e122#r138400765
...so code that compiles with Play 2.6.2 fails with Play 2.6.3. ...因此在Play 2.6.2中编译的代码在Play 2.6.3中失败。
Workarounds: 解决方法:
DefaultControllerComponents
- ie don't use MacWire for that particular constructor ...手动指定DefaultControllerComponents
的创建-即不要将MacWire用于该特定构造函数 That's not as pretty, but it works with Play 2.6.3: 那不是很漂亮,但可以在Play 2.6.3中使用:
val defaultControllerComponents = new DefaultControllerComponents(
defaultActionBuilder,
playBodyParsers,
messagesApi,
langs,
fileMimeTypes,
executionContext
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.