我有这个build.sbt文件,并且现在不推荐使用的语法(<< =)。如何更改文件以使其再次有效?我知道有一个页面记录了这些变化,但我无法正确理解它。
libraryDependencies <<= scalaVersion {
scala_version => Seq(
("org.apache.spark" % "spark-core_2.10" % "1.2.0").
exclude("org.eclipse.jetty.orbit", "javax.mail.glassfish").
exclude("org.eclipse.jetty.orbit", "javax.activation").
exclude("com.esotericsoftware.kryo", "minlog").
exclude("com.esotericsoftware.minlog", "minlog").
exclude("commons-beanutils", "commons-beanutils").
exclude("commons-beanutils", "commons-beanutils-core").
exclude("commons-logging", "commons-logging").
exclude("org.slf4j", "jcl-over-slf4j").
exclude("org.apache.hadoop", "hadoop-yarn-common").
exclude("org.apache.hadoop", "hadoop-yarn-api").
exclude("org.eclipse.jetty.orbit", "javax.transaction").
exclude("org.eclipse.jetty.orbit", "javax.servlet"),
("org.apache.spark" %% "spark-graphx" % "1.2.0").
exclude("org.eclipse.jetty.orbit", "javax.mail.glassfish").
exclude("org.eclipse.jetty.orbit", "javax.activation").
exclude("com.esotericsoftware.kryo", "minlog").
exclude("com.esotericsoftware.minlog", "minlog").
exclude("commons-beanutils", "commons-beanutils").
exclude("commons-beanutils", "commons-beanutils-core").
exclude("commons-logging", "commons-logging").
exclude("org.slf4j", "jcl-over-slf4j").
exclude("org.apache.hadoop", "hadoop-yarn-common").
exclude("org.apache.hadoop", "hadoop-yarn-api").
exclude("org.eclipse.jetty.orbit", "javax.transaction").
exclude("org.eclipse.jetty.orbit", "javax.servlet")
)
}
答案 0 :(得分:1)
查看来自sbt:
警告的migration guide链接[info] Loading global plugins from /.sbt/0.13/plugins
//tmp/build.sbt:3: warning: `<<=` operator is deprecated. Use `key := { x.value }` or `key ~= (old => { newValue })`.
See http://www.scala-sbt.org/0.13/docs/Migrating-from-sbt-012x.html
libraryDependencies <<= scalaVersion {
你可以看到你在这里属于最佳案例:
使用简单的表达式,例如:
a <<= aTaskDef
b <+= bTaskDef
c <++= cTaskDefs
用等价物替换它们就足够了:
a := aTaskDef.value
b += bTaskDef.value
c ++= cTaskDefs.value
所以aTaskDef
是{}
因此,您可以解决以下问题:
scalaVersion := "2.11.7"
libraryDependencies := scalaVersion {
scala_version => Seq(
("org.apache.spark" % "spark-core_2.10" % "1.2.0").
exclude("org.eclipse.jetty.orbit", "javax.mail.glassfish").
exclude("org.eclipse.jetty.orbit", "javax.activation").
exclude("com.esotericsoftware.kryo", "minlog").
exclude("com.esotericsoftware.minlog", "minlog").
exclude("commons-beanutils", "commons-beanutils").
exclude("commons-beanutils", "commons-beanutils-core").
exclude("commons-logging", "commons-logging").
exclude("org.slf4j", "jcl-over-slf4j").
exclude("org.apache.hadoop", "hadoop-yarn-common").
exclude("org.apache.hadoop", "hadoop-yarn-api").
exclude("org.eclipse.jetty.orbit", "javax.transaction").
exclude("org.eclipse.jetty.orbit", "javax.servlet"),
("org.apache.spark" %% "spark-graphx" % "1.2.0").
exclude("org.eclipse.jetty.orbit", "javax.mail.glassfish").
exclude("org.eclipse.jetty.orbit", "javax.activation").
exclude("com.esotericsoftware.kryo", "minlog").
exclude("com.esotericsoftware.minlog", "minlog").
exclude("commons-beanutils", "commons-beanutils").
exclude("commons-beanutils", "commons-beanutils-core").
exclude("commons-logging", "commons-logging").
exclude("org.slf4j", "jcl-over-slf4j").
exclude("org.apache.hadoop", "hadoop-yarn-common").
exclude("org.apache.hadoop", "hadoop-yarn-api").
exclude("org.eclipse.jetty.orbit", "javax.transaction").
exclude("org.eclipse.jetty.orbit", "javax.servlet")
)
}.value
你在问题中说:
但我无法理解它。
你究竟不懂什么?如果您可以详细说明它可能会帮助任何面临类似问题的人,如果我可能能够告诉您更多相关信息。