我到处寻找,但答案没有帮助。这是堆栈跟踪:
! @7832lo6ll - Internal server error, for (GET) [/] ->
play.api.UnexpectedException: Unexpected exception[ProvisionException: Unable to provision, see the following errors:
1) Could not find a suitable constructor in controllers.FileCtrl. Classes must have either one (and only one) constructor annotated with @Inject or a zero-argument constructor that is not private.
at controllers.FileCtrl.class(FileCtrl.scala:34)
while locating controllers.FileCtrl
for parameter 11 at router.Routes.<init>(Routes.scala:155)
while locating router.Routes
while locating play.api.inject.RoutesProvider
while locating play.api.routing.Router
1 error]
at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:165) ~[play-server_2.11-2.4.11.jar:2.4.11]
at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:121) ~[play-server_2.11-2.4.11.jar:2.4.11]
at scala.Option.map(Option.scala:146) ~[scala-library-2.11.8.jar:na]
at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:121) ~[play-server_2.11-2.4.11.jar:2.4.11]
at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:119) ~[play-server_2.11-2.4.11.jar:2.4.11]
at scala.util.Success.flatMap(Try.scala:231) ~[scala-library-2.11.8.jar:na]
at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1.apply(DevServerStart.scala:119) ~[play-server_2.11-2.4.11.jar:2.4.11]
at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1.apply(DevServerStart.scala:111) ~[play-server_2.11-2.4.11.jar:2.4.11]
at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24) ~[scala-library-2.11.8.jar:na]
at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24) ~[scala-library-2.11.8.jar:na]
Caused by: com.google.inject.ProvisionException: Unable to provision, see the following errors:
1) Could not find a suitable constructor in controllers.FileCtrl. Classes must have either one (and only one) constructor annotated with @Inject or a zero-argument constructor that is not private.
at controllers.FileCtrl.class(FileCtrl.scala:34)
while locating controllers.FileCtrl
for parameter 11 at router.Routes.<init>(Routes.scala:155)
while locating router.Routes
while locating play.api.inject.RoutesProvider
while locating play.api.routing.Router
1 error
at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1025) ~[guice-4.0.jar:na]
at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1051) ~[guice-4.0.jar:na]
at play.api.inject.guice.GuiceInjector.instanceOf(GuiceInjectorBuilder.scala:321) ~[play_2.11-2.4.11.jar:2.4.11]
at play.api.inject.guice.GuiceInjector.instanceOf(GuiceInjectorBuilder.scala:316) ~[play_2.11-2.4.11.jar:2.4.11]
at play.api.Application$class.routes(Application.scala:112) ~[play_2.11-2.4.11.jar:2.4.11]
at play.api.DefaultApplication.routes(Application.scala:241) ~[play_2.11-2.4.11.jar:2.4.11]
at play.api.Play$$anonfun$start$1.apply$mcV$sp(Play.scala:90) ~[play_2.11-2.4.11.jar:2.4.11]
at play.api.Play$$anonfun$start$1.apply(Play.scala:87) ~[play_2.11-2.4.11.jar:2.4.11]
at play.api.Play$$anonfun$start$1.apply(Play.scala:87) ~[play_2.11-2.4.11.jar:2.4.11]
at play.utils.Threads$.withContextClassLoader(Threads.scala:21) ~[play_2.11-2.4.11.jar:2.4.11]
FileCtrl.scala:
class FileCtrl @Inject()(actions: Actions, helpers: Helpers, errorHandler: ErrorHandler, cacheApi: CacheApi, fileDAO: FileDAO, companyFileService: CompanyFileService, imageService: ImageService, configuration: Configuration, settingService: SettingService, fileService: FileService)(val messagesApi: MessagesApi) extends Controller with I18nSupport with Flow {...
所以实际上有一个@Inject。
Play版本为2.4,Scala版本2.11.6
最让我困惑的是堆栈跟踪没有提到任何进一步的问题,例如,没有提到注入类可能是这里的问题。
答案 0 :(得分:0)
只是为了测试,也许你可以尝试使用normalApi的普通构造函数参数而不是curried版本?而不是
(val messagesApi: MessagesApi)
只需
([other constructor params ...], val messagesApi: MessagesApi)