spark 3.1.1
我试图使用带有&的 gradle 在 IntelliJ 中执行 scala 测试用例scala 2.12.13
。但是 scala 测试因以下jackson-databind
错误而失败。
val conf = new SparkConf().setMaster("local[2]")
val spark = SparkSession
.builder()
.config(conf)
.appName("Scala Test Cases")
.getOrCreate()
spark.sparkContext.setLogLevel("ERROR")
import spark.implicits._
Error initializing SparkContext.
com.fasterxml.jackson.databind.JsonMappingException: Scala module 2.12.4 requires Jackson Databind version >= 2.12.0 and < 2.13.0
at com.fasterxml.jackson.module.scala.JacksonModule.setupModule(JacksonModule.scala:61) ~[jackson-module-scala_2.12-2.12.4.jar:2.12.4]
at com.fasterxml.jackson.module.scala.JacksonModule.setupModule$(JacksonModule.scala:46) ~[jackson-module-scala_2.12-2.12.4.jar:2.12.4]
at com.fasterxml.jackson.module.scala.DefaultScalaModule.setupModule(DefaultScalaModule.scala:17) ~[jackson-module-scala_2.12-2.12.4.jar:2.12.4]
at com.fasterxml.jackson.databind.ObjectMapper.registerModule(ObjectMapper.java:808) ~[spark-cassandra-connector_2.12-3.0.0-jdk11-pie1.0.0.jar:3.0.0-jdk11-pie1.0.0]
at org.apache.spark.ui.exec.ExecutorsPage.<init>(ExecutorsTab.scala:82) ~[spark-core_2.12-3.1.1.15-apple.jar:3.1.1.15-apple]
at org.apache.spark.ui.exec.ExecutorsTab.init(ExecutorsTab.scala:41) ~[spark-core_2.12-3.1.1.15-apple.jar:3.1.1.15-apple]
at org.apache.spark.ui.exec.ExecutorsTab.<init>(ExecutorsTab.scala:34) ~[spark-core_2.12-3.1.1.15-apple.jar:3.1.1.15-apple]
at org.apache.spark.ui.SparkUI.initialize(SparkUI.scala:65) ~[spark-core_2.12-3.1.1.15-apple.jar:3.1.1.15-apple]
at org.apache.spark.ui.SparkUI.<init>(SparkUI.scala:81) ~[spark-core_2.12-3.1.1.15-apple.jar:3.1.1.15-apple]
at org.apache.spark.ui.SparkUI$.create(SparkUI.scala:184) ~[spark-core_2.12-3.1.1.15-apple.jar:3.1.1.15-apple]
at org.apache.spark.SparkContext.<init>(SparkContext.scala:480) ~[spark-core_2.12-3.1.1.15-apple.jar:3.1.1.15-apple]
at org.apache.spark.SparkContext$.getOrCreate(SparkContext.scala:2695) ~[spark-core_2.12-3.1.1.15-apple.jar:3.1.1.15-apple]
at org.apache.spark.sql.SparkSession$Builder.$anonfun$getOrCreate$2(SparkSession.scala:956) ~[spark-sql_2.12-3.1.1.15-apple.jar:3.1.1.15-apple]
at scala.Option.getOrElse(Option.scala:189) ~[scala-library-2.12.13.jar:?]
at org.apache.spark.sql.SparkSession$Builder.getOrCreate(SparkSession.scala:950) ~[spark-sql_2.12-3.1.1.15-apple.jar:3.1.1.15-apple]
at TestClass.getInputDF(TestClass.scala:597) ~[test/:?]
at TestClass.$anonfun$new$35(TestClass.scala:638) ~[test/:?]
at org.scalatest.OutcomeOf.outcomeOf(OutcomeOf.scala:85) ~[scalatest_2.12-3.0.4.jar:?]
at org.scalatest.OutcomeOf.outcomeOf$(OutcomeOf.scala:83) ~[scalatest_2.12-3.0.4.jar:?]
at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104) ~[scalatest_2.12-3.0.4.jar:?]
at org.scalatest.Transformer.apply(Transformer.scala:22) ~[scalatest_2.12-3.0.4.jar:?]
at org.scalatest.Transformer.apply(Transformer.scala:20) ~[scalatest_2.12-3.0.4.jar:?]
at org.scalatest.FlatSpecLike$$anon$1.apply(FlatSpecLike.scala:1682) ~[scalatest_2.12-3.0.4.jar:?]
at org.scalatest.TestSuite.withFixture(TestSuite.scala:196) ~[scalatest_2.12-3.0.4.jar:?]
at org.scalatest.TestSuite.withFixture$(TestSuite.scala:195) ~[scalatest_2.12-3.0.4.jar:?]
at org.scalatest.FlatSpec.withFixture(FlatSpec.scala:1685) ~[scalatest_2.12-3.0.4.jar:?]
at org.scalatest.FlatSpecLike.invokeWithFixture$1(FlatSpecLike.scala:1680) ~[scalatest_2.12-3.0.4.jar:?]
at org.scalatest.FlatSpecLike.$anonfun$runTest$1(FlatSpecLike.scala:1692) ~[scalatest_2.12-3.0.4.jar:?]
at org.scalatest.SuperEngine.runTestImpl(Engine.scala:289) ~[scalatest_2.12-3.0.4.jar:?]
at org.scalatest.FlatSpecLike.runTest(FlatSpecLike.scala:1692) ~[scalatest_2.12-3.0.4.jar:?]
at org.scalatest.FlatSpecLike.runTest$(FlatSpecLike.scala:1674) ~[scalatest_2.12-3.0.4.jar:?]
at org.scalatest.FlatSpec.runTest(FlatSpec.scala:1685) ~[scalatest_2.12-3.0.4.jar:?]
at org.scalatest.FlatSpecLike.$anonfun$runTests$1(FlatSpecLike.scala:1750) ~[scalatest_2.12-3.0.4.jar:?]
at org.scalatest.SuperEngine.$anonfun$runTestsInBranch$1(Engine.scala:396) ~[scalatest_2.12-3.0.4.jar:?]
at scala.collection.immutable.List.foreach(List.scala:431) ~[scala-library-2.12.13.jar:?]
at org.scalatest.SuperEngine.traverseSubNodes$1(Engine.scala:384) ~[scalatest_2.12-3.0.4.jar:?]
at org.scalatest.SuperEngine.runTestsInBranch(Engine.scala:379) ~[scalatest_2.12-3.0.4.jar:?]
at org.scalatest.SuperEngine.runTestsImpl(Engine.scala:461) ~[scalatest_2.12-3.0.4.jar:?]
at org.scalatest.FlatSpecLike.runTests(FlatSpecLike.scala:1750) ~[scalatest_2.12-3.0.4.jar:?]
at org.scalatest.FlatSpecLike.runTests$(FlatSpecLike.scala:1749) ~[scalatest_2.12-3.0.4.jar:?]
at org.scalatest.FlatSpec.runTests(FlatSpec.scala:1685) ~[scalatest_2.12-3.0.4.jar:?]
at org.scalatest.Suite.run(Suite.scala:1147) ~[scalatest_2.12-3.0.4.jar:?]
at org.scalatest.Suite.run$(Suite.scala:1129) ~[scalatest_2.12-3.0.4.jar:?]
at org.scalatest.FlatSpec.org$scalatest$FlatSpecLike$$super$run(FlatSpec.scala:1685) ~[scalatest_2.12-3.0.4.jar:?]
at org.scalatest.FlatSpecLike.$anonfun$run$1(FlatSpecLike.scala:1795) ~[scalatest_2.12-3.0.4.jar:?]
at org.scalatest.SuperEngine.runImpl(Engine.scala:521) ~[scalatest_2.12-3.0.4.jar:?]
at org.scalatest.FlatSpecLike.run(FlatSpecLike.scala:1795) ~[scalatest_2.12-3.0.4.jar:?]
at org.scalatest.FlatSpecLike.run$(FlatSpecLike.scala:1793) ~[scalatest_2.12-3.0.4.jar:?]
at org.scalatest.FlatSpec.run(FlatSpec.scala:1685) ~[scalatest_2.12-3.0.4.jar:?]
at org.scalatest.tools.SuiteRunner.run(SuiteRunner.scala:45) ~[scalatest_2.12-3.0.4.jar:?]
at org.scalatest.tools.Runner$.$anonfun$doRunRunRunDaDoRunRun$13(Runner.scala:1340) ~[scalatest_2.12-3.0.4.jar:?]
at org.scalatest.tools.Runner$.$anonfun$doRunRunRunDaDoRunRun$13$adapted(Runner.scala:1334) ~[scalatest_2.12-3.0.4.jar:?]
at scala.collection.immutable.List.foreach(List.scala:431) ~[scala-library-2.12.13.jar:?]
at org.scalatest.tools.Runner$.doRunRunRunDaDoRunRun(Runner.scala:1334) ~[scalatest_2.12-3.0.4.jar:?]
at org.scalatest.tools.Runner$.$anonfun$runOptionallyWithPassFailReporter$24(Runner.scala:1031) ~[scalatest_2.12-3.0.4.jar:?]
at org.scalatest.tools.Runner$.$anonfun$runOptionallyWithPassFailReporter$24$adapted(Runner.scala:1010) ~[scalatest_2.12-3.0.4.jar:?]
at org.scalatest.tools.Runner$.withClassLoaderAndDispatchReporter(Runner.scala:1500) ~[scalatest_2.12-3.0.4.jar:?]
at org.scalatest.tools.Runner$.runOptionallyWithPassFailReporter(Runner.scala:1010) ~[scalatest_2.12-3.0.4.jar:?]
at org.scalatest.tools.Runner$.run(Runner.scala:850) ~[scalatest_2.12-3.0.4.jar:?]
at org.scalatest.tools.Runner.run(Runner.scala) ~[scalatest_2.12-3.0.4.jar:?]
at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.runScalaTest2or3(ScalaTestRunner.java:38) ~[runners.jar:?]
at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.main(ScalaTestRunner.java:25) ~[runners.jar:?]
2021-08-12 15:24:54,556 INFO o.a.s.i.Logging [dispatcher-event-loop-0] MapOutputTrackerMasterEndpoint stopped!
我正在导入scalatest
& holdenkarau
in build.gradle
:
testImplementation("org.scalatest:scalatest_2.12:3.0.4") {
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-databind'
}
testImplementation("com.holdenkarau:spark-testing-base_2.12:3.0.1_1.1.0"){
exclude group: 'org.apache.xbean', module: 'xbean-asm6'
}
这些测试在使用spark 2.4.7
&scala 2.11.12
与以下依赖版本时运行良好。
testCompile("org.scalatest:scalatest_2.11:3.0.4")
testCompile("com.holdenkarau:spark-testing-base_2.11:2.4.5_0.14.0"){
exclude group: 'org.apache.xbean', module: 'xbean-asm6'
}
不知道我在这里错过了什么。我尝试强制更新杰克逊库,但仍然没有解决问题。
configurations.configureEach {
resolutionStrategy {
force "com.fasterxml.jackson.module:jackson-module-scala_2.12:2.12.4"
force "com.fasterxml.jackson.core:jackson-databind:2.12.4"
force "com.fasterxml.jackson.core:jackson-core:2.12.4"
force "com.fasterxml.jackson.core:jackson-annotations:2.12.4"
force "com.fasterxml.jackson.module:jackson-module-jaxb-annotations:2.12.4"
force "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:2.12.4"
force "com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:2.12.4"
force "org.scalatest:scalatest_2.12:3.0.4"
}
}