Jackson 的JAR包冲突问题

在maven编译过程中发现报出了如下的错误:

Exception in thread "main" java.lang.ExceptionInInitializerError
        at org.apache.spark.SparkContext.withScope(SparkContext.scala:701)
        at org.apache.spark.SparkContext.textFile(SparkContext.scala:830)
        at org.apache.spark.api.java.JavaSparkContext.textFile(JavaSparkContext.scala:172)
        at com.getui.test.spark.TextIO.main(TextIO.java:12)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.apache.hadoop.util.RunJar.run(RunJar.java:318)
        at org.apache.hadoop.util.RunJar.main(RunJar.java:232)
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Incompatible Jackson version: 2.9.5
        at com.fasterxml.jackson.module.scala.JacksonModule$class.setupModule(JacksonModule.scala:64)
        at com.fasterxml.jackson.module.scala.DefaultScalaModule.setupModule(DefaultScalaModule.scala:19)
        at com.fasterxml.jackson.databind.ObjectMapper.registerModule(ObjectMapper.java:751)
        at org.apache.spark.rdd.RDDOperationScope$.(RDDOperationScope.scala:82)
        at org.apache.spark.rdd.RDDOperationScope$.(RDDOperationScope.scala)
        ... 10 more

后台查阅资料与查看报错发现,是由于Jackson这个工具库的版本不一致导致的。

解决方案:

排除其他对于Jackon的依赖,从而阻止Maven自动导入高版本的库:


    
        com.fasterxml.jackson.module
        *
    
    
        com.fasterxml.jackson.core
        *
    

随后手动添加相同版本Jackon库的依赖项,重新import即可。


    com.fasterxml.jackson.module
    jackson-module-scala_2.10
    2.9.5



    com.fasterxml.jackson.module
    jackson-module-paranamer
    2.9.5

 

    com.fasterxml.jackson.module
    jackson-module-jaxb-annotations
    2.9.5



你可能感兴趣的:(报错,冲突报错,jackson)