I'm trying Play 2.4.2 for Scala and I'm not clear whether controllers should be defined as classes or singletons. The docs state:
A Controller is nothing more than a singleton object that generates Action values.
However the code sample shows:
class Application extends Controller { ... }
To further complicate things, intellij gives me a warning if I define a class:
However I get a compilation error (but no warning) if I use a singleton:
package controllers
import play.api._
import play.api.mvc._
object Application extends Controller { ... }
Error:(6, -1) Play 2 Compiler: /Users/Toby/IdeaProjects/play-scala/conf/routes:6: type Application is not a member of package controllers
Which approach is correct?
object Application extends Controller
, or as class if you need Dependency Injection. – cchantep