[英]MacWire: Found multiple values of type
我正在使用MacWire DI框架,但出现此错误。
Found multiple values of type [play.api.mvc.DefaultActionBuilder]: [List(defaultActionBuilder, Action)]
[error] override lazy val controllerComponents: DefaultControllerComponents = wire[DefaultControllerComponents]
我的应用程序加载器是这样的:
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]
在对代码进行少量修改之后,我得到了其他一些类似的错误。 如何遵循DI依赖关系来跟踪这些错误?
我本人刚遇到此问题,似乎是由于此提交,在Play 2.6.3中作为反向端口包括在内:
...因此在Play 2.6.2中编译的代码在Play 2.6.3中失败。
解决方法:
DefaultControllerComponents
的创建-即不要将MacWire用于该特定构造函数 那不是很漂亮,但可以在Play 2.6.3中使用:
val defaultControllerComponents = new DefaultControllerComponents(
defaultActionBuilder,
playBodyParsers,
messagesApi,
langs,
fileMimeTypes,
executionContext
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.