1

I'm trying to move to compile-time dependency injection using Play Framework 2.6 in Java. My reading of the Play 2.6 Migration Guide under "Scala Controller Changes", leads me to believe that I should pass an instance of ControllerComponents into my controller classes; but I can't find a method that provides those components.

play.api.BuiltInComponentsFromContext defines a controllerComponents() method, but the Java version of that class, play.BuiltInComponentsFromContext, does not.

What is going on?

Under "Using Dependency Injection" in the Play 2.6 (Java) documentation, it talks about overriding javaHandlerComponents in BuiltInComponents. OK fine, but does that mean I have to define all of my actions as separate classes? Can I not use Controller classes if I want to do compile-time dependency injection in Java?

4

1 回答 1

0

Play 2.6 迁移指南中标题为“Scala Controller Changes”的部分命名正确:它仅适用于用 Scala 编写的控制器。使用您在 2.6 之前使用的相同动作组合方法。

于 2017-08-30T03:45:23.593 回答