当我使用sbt程序集时,它会输出如下错误:
[error] (*:assembly) scala.MatchError: org\apache\commons\io\IOCase.class (of class java.lang.String)
这些是我的配置:
1,的 assembly.sbt:
import AssemblyKeys._
assemblySettings
mergeStrategy in assembly := {
case PathList("org", "springframework", xs@_*) => MergeStrategy.last
}
2,的 bulid.sbt
import AssemblyKeys._
lazy val root = (project in file(".")).
settings(
name := "DmpRealtimeFlow",
version := "1.0",
scalaVersion := "2.11.8",
libraryDependencies += "com.jd.ads.index" % "ad_index_dmp_common" % "0.0.4-SNAPSHOT",
libraryDependencies += "org.apache.spark" % "spark-core_2.11" % "2.1.0" % "provided",
libraryDependencies += "org.apache.spark" % "spark-sql_2.11" % "2.1.0" % "provided",
libraryDependencies += "org.apache.spark" % "spark-streaming_2.11" % "2.1.0" % "provided",
libraryDependencies += "mysql" % "mysql-connector-java" % "5.1.8",
libraryDependencies += "org.springframework" % "spring-beans" % "3.1.0.RELEASE",
libraryDependencies += "org.springframework" % "spring-context" % "3.1.0.RELEASE",
libraryDependencies += "org.springframework" % "spring-core" % "3.1.0.RELEASE",
libraryDependencies += "org.springframework" % "spring-orm" % "3.1.0.RELEASE",
libraryDependencies += "org.mybatis" % "mybatis" % "3.2.1" % "compile",
libraryDependencies += "org.mybatis" % "mybatis-spring" % "1.2.2",
libraryDependencies += "c3p0" % "c3p0" % "0.9.1.2"
)
3,项目工具:
sbt:0.13.5
assembly:0.11.2
java:1.7
scala:2.11.8
任何帮助?
答案 0 :(得分:0)
问题可能出在程序集块中mergeStrategy中缺少的默认情况:
case x =>
val oldStrategy = (assemblyMergeStrategy in assembly).value
oldStrategy(x)
此外,不推荐使用mergeStrategy,而应使用assemblyMergeStrategy。
基本上是
{
case PathList("org", "springframework", xs@_*) => MergeStrategy.last
}
是部分函数String => MergeStrategy仅针对一种类型的输入定义,即对于包前缀为“org \ springframework”的类。但是,它适用于项目中的所有类文件,并且第一个与上面的前缀不匹配的文件(org \ apache \ commons \ io \ IOCase.class)会导致MatchError。