Reputation: 8043
activator new play-scala-intro play-scala-intro
File
-> Import project from Existing sources
and selected SBT
.This is default project structure:
I've also tried all tips from here (suggested for for Play 2.2 — 2.3, whereas I have Play 2.4). But I haven't tried to add target/scala-*/classes_managed
to sources because my project doesn't contain this folder.
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.1")
scalaVersion := "2.11.6"
Upvotes: 4
Views: 1694
Reputation: 184
Looking at the documentation Play documentation for 2.4 version here - https://www.playframework.com/documentation/2.4.x/ScalaRouting it specifically states that -
Play supports generating two types of routers, one is a dependency injected router, the other is a static router. The default is the static router, but if you created a new Play application using the Play seed Activator templates, your project will include the following configuration in build.sbt telling it to use the injected router:
routesGenerator := InjectedRoutesGenerator
Hence if you check you build.sbt, it would have a line -
routesGenerator := InjectedRoutesGenerator
Indicating that the default router is the dependency injected router.
Hence to avoid the error, you would have to append @ to the controllers in the routes file as stated here https://www.playframework.com/documentation/2.4.x/ScalaRouting -
The code samples in Play’s documentation assumes that you are using the injected routes generator. If you are not using this, you can trivially adapt the code samples for the static routes generator, either by prefixing the controller invocation part of the route with an @ symbol, or by declaring each of your controllers as an object rather than a class.
Upvotes: 0
Reputation: 767
My IntelliJ IDEA version is 14.1.4, add a @
symbol before the controllers
like this:
GET / @controllers.Application.index
The IDE won't report a Cannot resolve ...
message.
Upvotes: 3
Reputation: 11498
JetBrains hasn't yet updated their Scala/Play plugin to reflect the new routing structure with Play 2.4 (using classes instead of objects for the controllers, for example). You can ignore those errors, run the app and it'll be all fine.
See the ongoing issue ticket over on https://youtrack.jetbrains.com/issue/SCL-8812 for more. One comment says: "This got fixed in the recent EAP Build of IntelliJ and Scala 1.6.27.1.EAP also IntelliJ EAP 15 looks really good in his current state."
You can wait for IntelliJ 15. In the meanwhile, ignore the errors which are wrongly flagged by IntelliJ 14 and older versions.
Upvotes: 5