Search code examples
scalaintellij-ideareactivemongoplay-reactivemongo

Cannot resolve symbol in routes file with intellij 14 and play framework 2.4 reactivemongo


I'm using IntelliJ 14.1.4 and Play framework 2.4. I copied some code from this github project: https://github.com/JAVEO/play-reactivemongo-polymer to test out reactivemongo. Basically, I copied the Posts.scala to my controller folder. It's a class:

package controllers

import javax.inject.Inject

import play.api.libs.concurrent.Execution.Implicits.defaultContext
import play.api.libs.json.Json
import play.api.mvc.{Action, BodyParsers, Call, Controller, Result}
import play.modules.reactivemongo.{MongoController, ReactiveMongoApi, ReactiveMongoComponents}
import reactivemongo.api.commands.WriteResult
import reactivemongo.bson.{BSONDocument, BSONObjectID}
import reactivemongo.core.actors.Exceptions.PrimaryUnavailableException

class Posts @Inject()(val reactiveMongoApi: ReactiveMongoApi)
  extends Controller with MongoController with ReactiveMongoComponents {
...
}

in the routes file, IntellJ cannot resolve this line:

GET     /api/posts                  controllers.Posts.list

It seems that IntellJ only recognize controllers declared as object but not class.

Trying to run this using activator got the compilation error:

No Json serializer as JsObject found for type play.api.libs.json.JsObject. Try to implement an implicit OWrites or OFormat for this type
...

Any help?


Solution

  • Upgrade plugin and intellij to the latest version solved the problem. Looks like a bug.