目前,我正在使用Scala的PlayFramework2.4开发一个小型轻松的Rest。我确实定义了一个简单的case类,这个类很容易转换成Json。现在,我希望对象(如果结果是一个列表,这个列表中的每个条目)被命名。
这是一种简单的方式吗?我刚刚找到了,但它并没有真正解决我的问题。
case class Employee(name: String, address: String, dob: Date, joiningDate: Date, designation: String)
// Generates Writes and Reads for Feed and User thanks
注意:我对PlayFramework非常陌生。 我正在尝试将item对象序列化为JSON字符串。我收到以下错误: No instance of play.api.libs.json.Format is available for
scala.collection.immutable.List[Item] in the implicit scope (Hint: if declared
in the same file, make sure it's declared before)
[error] implicit val itemRESTFormat: Format
我正在尝试创建PlayFramework Scala种子项目。
到目前为止,我已经使用了sbt new playframework/play-scala-seed.g8命令,它已经在我的根目录movie-app中创建了必要的文件。
从这里开始,PlayFramework说要运行sbt run,所以我尝试了,但是我得到了以下错误:
[info] Updated file *omitting personal directories*/Movie-App/project/build.properties: set sbt.version to 1.4.7
[info] welcome to sbt
我正在尝试在Playframework 2.4上构建应用程序。我得到了这个例外。热心的帮助和帮助。
play.http.errorHandler [utils.ErrorHandler] was not loaded.
No source available, here is the exception stack trace:
->java.lang.ClassNotFoundException: utils.ErrorHandler
java.net.URLClassLoader.findClass(URLClassLoader.java:381)
java
我正在使用Java 1.7.0_15和2.10.0来使用play 2.1.1 Scala。
当我试图将ArrayList的内容作为HashMap访问时,错误([NullPointerException: null]) I跳过两者。
我尝试过两种方式:
首先,在构造函数中是初始化的属性:
import java.util.ArrayList;
import java.util.HashMap;
public Class User extends Model {
...
public User(...) {
...
countriesVisited = new ArrayList<C
我正在使用带有Anorm的playframework 2.1.0来查询数据库。我希望将结果序列化为json,而不需要经过任何中间对象/case类。
这是流程的样子:使用anorm:
DB.withConnection { implicit c =>
val q = SQL(""" long query goes here """)
q().toList
}
然后,我将这个结果从一个ListSqlRow转换为List[MapString,Any]。字符串,Any是列名,value (Object/Any)
val asMap = in
我正在尝试解析来自远程http响应的play框架中的一些json。我正在尝试进入results->locations->latLng->lat。我在scala中使用playframework 2.0。
下面是我正在使用的代码,以及一些我到目前为止已经尝试过的注释示例。
val promise = WS.url("http://www.mapquestapi.com/geocoding/v2/address?...").get()
val body = promise.value.get.body
val json = Json.parse(body
在使用scala/playframework时,需要在slick 3.0.2中更新表。
form.fold (
errForm => {
BadRequest();
},
data => {
** update each column of the table after running db.run
}
)
这不能编译:
package model
import play.api.libs.json._
case class Dog(id: Long, name: String, kind: String) {
def asJson() = Json.toJson(this)
}
object Dog {
implicit val writes = Json.writes[Dog]
}
错误:
53. Waiting for source changes... (press enter to interrupt)
[info] Compiling 1 Scala source to
有人问过一个,但我觉得它没有多大帮助。我将MyRepository注射到MyActor中。在启动时,我会得到以下例外:
[error] - akka.actor.OneForOneStrategy - Unable to provision, see the following errors:
1) Error injecting constructor, java.lang.RuntimeException: There is no started application
at infrastructure.repository.MyRepository.<init>(My
我在用这出戏!框架,并尝试在Specs2测试中处理JSON响应消息,但没有成功。
我尝试做的是在JsValue中声明键->值对,如下面的示例所示……但我不能让火柴盒正确通过。
import org.specs2.mutable._
import play.api.libs.json.{Json, JsValue}
class JsonSpec extends Specification {
"Json Matcher" should {
"Correctly match Name->Value pairs" in {
v
大家好,我收到了这个不推荐使用的警告
在我使用scala和slick的playframework应用程序中
[warn]
\app\dto\processTemplateDTO.scala:95: method columnToOptionColumn in trait API is deprecated: Use an explicit conversion to an Option column with `.?`
[warn] def processtemplateFK: ForeignKeyQuery[ProcessTemplates, ProcessTemplatesMod