2017-04-18 55 views
0

我是Scala的新成員,嘗試使用AWS Lambda函數進行實驗。我正在關注這篇文章:https://aws.amazon.com/blogs/compute/writing-aws-lambda-functions-in-scala/這個Scala代碼中的錯誤在哪裏?

我用這段代碼創建了一個build.sbt文件。

javacOptions ++= Seq("-source", "1.8", "-target", "1.8", "-Xlint") 

lazy val root = (project in file(".")). 
    settings(
    name := "lambda-demo", 
    version := "1.0", 
    scalaVersion := "2.11.4", 
    retrieveManaged := true, 
    libraryDependencies += "com.amazonaws" % "aws-lambda-java-core" % "1.0.0", 
    libraryDependencies += "com.amazonaws" % "aws-lambda-java-events" % "1.0.0" 
) 

mergeStrategy in assembly < 
    { 
    case PathList("META-INF", xs @ _*) => MergeStrategy.discard 
    case x => MergeStrategy.first 
    } 
} 

但是,當我嘗試編譯時,我得到幾個錯誤之一,這取決於我如何嘗試修復它。一個這樣的錯誤是:

/build.sbt:14: error: value < is not a member of sbt.TaskKey[sbt.File] 
mergeStrategy in assembly < 

這對我來說幾乎是完全陌生的。

回答

2

相信你已經在這條線的鬆散角度支架:

mergeStrategy in assembly < 

和你正在尋找的語法是這樣的:

mergeStrategy in assembly := { 
    case PathList("META-INF", xs @ _*) => MergeStrategy.discard 
    case x => MergeStrategy.first 
} 

這也可能是:

assemblyMergeStrategy in assembly := { /* Same case statements */ } 

Here是指向您用來創建JAR的sbt-assembly項目的鏈接。那裏有更多的例子。


編輯的評論:

合併戰略需要是root.settings的一部分:

javacOptions ++= Seq("-source", "1.8", "-target", "1.8", "-Xlint") 

lazy val root = (project in file(".")). 
    settings(
    name := "lambda-demo", 
    version := "1.0", 
    scalaVersion := "2.11.4", 
    retrieveManaged := true, 
    libraryDependencies += "com.amazonaws" % "aws-lambda-java-core" % "1.0.0", 
    libraryDependencies += "com.amazonaws" % "aws-lambda-java-events" % "1.0.0", 
    assemblyMergeStrategy in assembly := { 
     case PathList("META-INF", xs @ _*) => MergeStrategy.discard 
     case x => MergeStrategy.first 
    } 
) 
+0

,修復了錯誤,但現在卻抱怨缺少分號在最後線。 build.sbt]:18:';'預計但eof發現。我會看看你包含的鏈接。 Thx非常。 –

+0

@DannyEllisJr。我用你需要的完整'build.sbt'文件編輯我的答案 – Tyler

+1

解決了這個問題。在其他地方爆炸,但這應該是一個不同的問題。謝謝一堆。 –