Scala,Play2.0 - 期待';'但发现')'

时间:2011-12-21 16:36:40

标签: scala playframework-2.0

对于像我这样的新手Scala程序员来说,这似乎是一个常见的主题......

val main = PlayProject(appName, appVersion, appDependencies).settings(defaultJavaSettings:_*).settings(
    resolvers += Resolver.file("private") artifacts "C:/java/repository/[organisation]/[module]/[revision]/[artifact].[ext]" ivys "C:/java/repository/[organisation]/[module]/ivy-[revision].xml"
    resolvers += Resolver.url("public") artifacts "https://foo.com/ivy-repository/[organisation]/[module]/[revision]/[artifact].[ext]" ivys "https://foo.com/ivy-repository/[organisation]/[module]/ivy-[revision].xml"
)

这两行共同产生错误:

[error] C:\java\play-2.0-beta\base\project\Build.scala:16: ')' expected but '.' found.
[error]         resolvers += Resolver.url("webster") artifacts "https://dev.blackrock.com/ivy-repository/[organisation]/[module]/[revision]/[artifact].[ext]" ivys "https://dev.blackrock.com/ivy-repository/[organisation]/[module]/ivy-[revision].xml"
[error]                              ^
[error] C:\java\play-2.0-beta\base\project\Build.scala:17: ';' expected but ')' found.
[error]     )
[error]     ^
[error] two errors found

如果我删除一行,它可以工作,无论哪一行。改变线条的顺序没有区别。

有人能引导我吗?

4 个答案:

答案 0 :(得分:6)

这里的问题是results += ....是一个参数。你写的内容基本上是这样的:

val main = PlayProject(...).settings(a b)

你应该写的是:

val main = PlayProject(...).settings(a, b) // put in a comma!

虽然你也可以这样写:

val main = PlayProject(appName, appVersion, appDependencies).settings(defaultJavaSettings:_*).settings(
  resolvers ++= Seq(
    Resolver.file("private") artifacts "C:/java/repository/[organisation]/[module]/[revision]/[artifact].[ext]" ivys "C:/java/repository/[organisation]/[module]/ivy-[revision].xml",
    Resolver.url("public") artifacts "https://foo.com/ivy-repository/[organisation]/[module]/[revision]/[artifact].[ext]" ivys "https://foo.com/ivy-repository/[organisation]/[module]/ivy-[revision].xml"
  )
)

答案 1 :(得分:1)

将两次调用链接到设置可以解决问题。

val main = PlayProject(appName, appVersion, appDependencies).settings(defaultJavaSettings:_*).settings(
    resolvers += Resolver.file("private") artifacts "C:/java/repository/[organisation]/[module]/[revision]/[artifact].[ext]" ivys "C:/java/repository/[organisation]/[module]/ivy-[revision].xml"
).settings(
    resolvers += Resolver.url("public") artifacts "https://foo.com/ivy-repository/[organisation]/[module]/[revision]/[artifact].[ext]" ivys "https://foo.com/ivy-repository/[organisation]/[module]/ivy-[revision].xml"
)

答案 2 :(得分:0)

不要忘记跳过解析器之间的界限。

答案 3 :(得分:0)

你只是错过了第一个和第二个解析器之间的逗号

val main = PlayProject(appName, appVersion, appDependencies).settings(defaultJavaSettings:_*).settings(
      resolvers += Resolver.file("private") artifacts "C:/java/repository/[organisation]/[module]/[revision]/[artifact].[ext]" ivys "C:/java/repository/[organisation]/[module]/ivy-[revision].xml"
    , resolvers += Resolver.url("public") artifacts "https://foo.com/ivy-repository/[organisation]/[module]/[revision]/[artifact].[ext]" ivys "https://foo.com/ivy-repository/[organisation]/[module]/ivy-[revision].xml"
)