尝试运行assembly
时出现重复数据删除错误。我已经为我的合并策略使用了许多不同的方法来尝试解决问题,但它们似乎都没有用。
sbt输出错误
[warn] Merging 'META-INF\DUMMY.DSA' with strategy 'discard'
[warn] Merging 'META-INF\DUMMY.SF' with strategy 'discard'
[warn] Merging 'META-INF\ECLIPSEF.SF' with strategy 'discard'
[warn] Merging 'META-INF\INDEX.LIST' with strategy 'discard'
[warn] Merging 'META-INF\MANIFEST.MF' with strategy 'discard'
[warn] Merging 'META-INF\services\java.sql.Driver' with strategy 'filterDistinctLines'
[warn] Merging 'META-INF\spring.handlers' with strategy 'filterDistinctLines'
[warn] Merging 'META-INF\spring.schemas' with strategy 'filterDistinctLines'
[debug] Merging 'META-INF\spring.tooling' with strategy 'deduplicate'
java.lang.RuntimeException: deduplicate: different file contents found in the following:
C:\Users\Matthew\.ivy2\cache\org.springframework\spring-jdbc\jars\spring-jdbc-4.0.5.RELEASE.jar:META-INF/spring.tooling
C:\Users\Matthew\.ivy2\cache\org.springframework\spring-beans\jars\spring-beans-4.0.5.RELEASE.jar:META-INF/spring.tooling
C:\Users\Matthew\.ivy2\cache\org.springframework\spring-tx\jars\spring-tx-4.0.5.RELEASE.jar:META-INF/spring.tooling
和build.scala
import com.mojolly.scalate.ScalatePlugin.ScalateKeys._
import com.mojolly.scalate.ScalatePlugin._
import org.scalatra.sbt._
import sbt.Keys._
import sbt._
import sbtassembly.Plugin._
import sbtassembly.Plugin.AssemblyKeys._
object ScalatraBuild extends Build {
val Organization = "com.my.myproject"
val Name = "myproject"
val Version = "0.1.0-SNAPSHOT"
val ScalaVersion = "2.11.1"
val ScalatraVersion = "2.3.0"
val port = SettingKey[Int]("port")
val Conf = config("container")
lazy val project = Project(
"myproject-platform",
file("."),
settings = Defaults.defaultConfigs ++ ScalatraPlugin.scalatraWithJRebel ++ net.virtualvoid.sbt.graph.Plugin.graphSettings ++ scalateSettings ++ assemblySettings ++ Seq(
port in Conf := 8080,
organization := Organization,
name := Name,
version := Version,
scalaVersion := ScalaVersion,
resolvers ++= Seq("Sonatype OSS Snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/",
"RoundEights" at "http://maven.spikemark.net/roundeights",
Resolver.sonatypeRepo("releases")),
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-compiler" % "2.11.1",
"org.scalatra" %% "scalatra" % ScalatraVersion,
"org.scalatra" %% "scalatra-scalate" % ScalatraVersion,
"org.scalatra" %% "scalatra-scalatest" % ScalatraVersion % "test",
"org.scalatra" %% "scalatra-auth" % "2.3.0",
"org.scalatra" %% "scalatra-json" % "2.3.0",
"org.json4s" %% "json4s-jackson" % "3.2.10",
"org.json4s" %% "json4s-ext" % "3.2.10",
"org.json4s" %% "json4s-core" % "3.2.10",
"com.chuusai" %% "shapeless" % "2.0.0",
"com.github.julien-truffaut" %% "monocle-core" % "0.5.1",
"com.github.julien-truffaut" %% "monocle-generic" % "0.5.1",
"com.github.julien-truffaut" %% "monocle-macro" % "0.5.1",
"com.roundeights" %% "mailgun-scala" % "0.2",
"com.roundeights" %% "scalon" % "0.2",
"net.databinder.dispatch" %% "dispatch-core" % "0.11.1",
"com.escalatesoft.subcut" %% "subcut" % "2.1",
"com.typesafe" % "config" % "1.2.1",
"ch.qos.logback" % "logback-classic" % "1.0.13" % "runtime",
"org.codehaus.janino" % "janino" % "2.6.1",
"org.eclipse.jetty" % "jetty-webapp" % "8.1.8.v20121106" % "container;compile",
"org.apache.derby" % "derby" % "10.10.1.1",
"c3p0" % "c3p0" % "0.9.1.2",
"org.eclipse.jetty.orbit" % "javax.servlet" % "3.0.0.v201112011016" % "compile;container;provided;test" artifacts (Artifact("javax.servlet", "jar", "jar")),
"com.googlecode.mapperdao" %% "mapperdao" % "1.0.1",
"mysql" % "mysql-connector-java" % "5.1.18",
"commons-dbcp" % "commons-dbcp" % "1.4",
"com.stripe" % "stripe-java" % "1.18.0"
),
mergeStrategy in assembly <<= (mergeStrategy in assembly) {
(old) => {
case PathList(xs@_*) if xs.last endsWith ".tooling" => MergeStrategy.first
case PathList("META-INF", "spring.tooling") => MergeStrategy.first
case PathList("META-INF", xs @ _*) =>
(xs map {_.toLowerCase}) match {
case "spring.tooling" :: Nil => MergeStrategy.first
}
case x => old(x)
}
},
scalateTemplateConfig in Compile <<=(sourceDirectory in Compile) { base =>
Seq(
TemplateConfig(
base / "webapp" / "WEB-INF" / "templates",
Seq.empty, /* default imports should be added here */
Seq.empty, /* add extra bindings here */
Some("templates")
)
)
}
)
)
}
正如你所看到的,我尝试了一些不同的东西,但没有一个看到与案例相符。我可以帮忙吗?
答案 0 :(得分:2)
试试这个
case x if x.endsWith("spring.tooling") => MergeStrategy.last
对我来说,构建文件看起来不错,但您可以尝试添加&#39; println&#39;看看是否使用了实际的自定义合并策略的语句,也许sbt-assembly没有看到它
答案 1 :(得分:0)
我在项目的根目录中使用了assembly.sbt
文件,但在build.scala
中指定了合并策略设置。将设置移动到此文件后,一切正常。