我使用playframework2.2:尝试构建一个游戏支持项目。
在我的Build.scala中,我想添加play.Project.playJavaSetting:
val main = play.Project(appName, appVersion, appDependencies)
.settings(play.Project.playJavaSettings) //error here
.settings(
resolvers += "webjars" at "http://webjars.github.com/m2",
resolvers += "typesafe" at "http://repo.typesafe.com/typesafe/release"
)
错误是:
[error] F:\git\play-example-form\project\Build.scala:19: overloaded method value
settings with alternatives:
[error] (ss: sbt.Def.Setting[_]*)sbt.Project <and>
[error] => Seq[sbt.Def.Setting[_]]
[error] cannot be applied to (Seq[sbt.Setting[_]])
[error] .settings(play.Project.playJavaSettings)
[error] ^
如果我不添加playJavaSetting,它会给我错误的收集申请错误,我的意思是:
val main = play.Project(appName, appVersion, appDependencies)
//.settings(play.Project.playJavaSettings)
,错误是:
[error] required: play.api.data.Form<StudentFormData>,scala.collection.immutab
le.Map<String,Object>,scala.collection.immutable.List<String>,scala.collection.i
mmutable.Map<String,Object>,scala.collection.immutable.Map<String,Object>
[error] found: play.data.Form<StudentFormData>,java.util.Map<String,Boolean>,j
ava.util.List<String>,java.util.Map<String,Boolean>,java.util.Map<String,Boolean
你可以看到框架应用了scala.collection.immutable.List而不是play.util.List,如果我真的想应用java集合如何在Build.scala文件中设置环境设置?
答案 0 :(得分:2)
你应该改变
.settings(play.Project.playJavaSettings)
到
.settings(play.Project.playJavaSettings:_ *)
settings
方法声明为def settings(ss: Setting[_]*)
,这意味着它需要重复Setting[_]
类型的参数。 play.Project.playJavaSettings
的类型为Seq[Setting[_]]
。要将一个转换为另一个,Scala有一个特殊的类型注释。
如果您对详细信息感兴趣,请检查The Scala Language Specification
的 4.6.2重复参数