我使用IntelliJ 14.1.4和Play框架2.4。我从这个github项目中复制了一些代码:https://github.com/JAVEO/play-reactivemongo-polymer来测试reactivemongo。基本上,我将Posts.scala复制到我的控制器文件夹中。这是一堂课:
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 {
...
}
在路由文件中,IntellJ无法解析此行:
GET /api/posts controllers.Posts.list
似乎IntellJ只识别声明为对象但不是类的控制器。
尝试使用激活器运行此操作会出现编译错误:
No Json serializer as JsObject found for type play.api.libs.json.JsObject. Try to implement an implicit OWrites or OFormat for this type
...
任何帮助?
答案 0 :(得分:0)
升级插件和intellij到最新版本解决了问题。看起来像个bug。