报错NoClassDefFoundError: com/fasterxml/jackson/core/json/JsonWriteFeature; omitted for conflict with

这篇具有很好参考价值的文章主要介绍了报错NoClassDefFoundError: com/fasterxml/jackson/core/json/JsonWriteFeature; omitted for conflict with。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/json/JsonWriteFeature
报错NoClassDefFoundError: com/fasterxml/jackson/core/json/JsonWriteFeature; omitted for conflict with,IDEA,Error,json,spark,scala
原因是需要的fasterxml的版本包和其他包里面的旧版本重复而丢弃

运行命令:
mvn dependency:tree -Dverbose -Dincludes=*fasterxml*:*databind*
找出所有包含*fasterxml*:*jackson*的包:

[INFO] 
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ sr-flow-api ---
[INFO] com.huawei.ccloud.sparkle.search:sr-flow-api:jar:1.0.0-SNAPSHOT
[INFO] +- org.apache.spark:spark-mllib_2.12:jar:3.0.1:provided
[INFO] |  +- org.apache.spark:spark-core_2.12:jar:3.0.1:provided
[INFO] |  |  +- org.apache.spark:spark-kvstore_2.12:jar:3.0.1:provided
[INFO] |  |  |  \- (com.fasterxml.jackson.core:jackson-databind:jar:2.10.0:provided - omitted for duplicate)
[INFO] |  |  +- org.apache.spark:spark-network-common_2.12:jar:3.0.1:provided
[INFO] |  |  |  \- (com.fasterxml.jackson.core:jackson-databind:jar:2.10.0:provided - omitted for duplicate)
[INFO] |  |  +- io.dropwizard.metrics:metrics-json:jar:4.1.1:provided
[INFO] |  |  |  \- (com.fasterxml.jackson.core:jackson-databind:jar:2.9.9.3:provided - omitted for conflict with 2.10.0)
[INFO] |  |  +- (com.fasterxml.jackson.core:jackson-databind:jar:2.10.0:provided - omitted for conflict with 2.6.3)
[INFO] |  |  \- com.fasterxml.jackson.module:jackson-module-scala_2.12:jar:2.10.0:provided
[INFO] |  |     +- (com.fasterxml.jackson.core:jackson-databind:jar:2.10.0:provided - omitted for duplicate)
[INFO] |  |     \- com.fasterxml.jackson.module:jackson-module-paranamer:jar:2.10.0:provided
[INFO] |  |        \- (com.fasterxml.jackson.core:jackson-databind:jar:2.10.0:provided - omitted for duplicate)
[INFO] |  \- org.apache.spark:spark-sql_2.12:jar:3.0.1:provided
[INFO] |     \- (com.fasterxml.jackson.core:jackson-databind:jar:2.10.0:provided - omitted for duplicate)
[INFO] +- org.apache.kafka:kafka-streams:jar:0.10.0.0:provided
[INFO] |  +- org.apache.kafka:connect-json:jar:0.10.0.0:provided
[INFO] |  |  \- (com.fasterxml.jackson.core:jackson-databind:jar:2.6.3:provided - omitted for conflict with 2.10.0)
[INFO] |  \- com.fasterxml.jackson.core:jackson-databind:jar:2.6.3:provided
[INFO] +- org.apache.spark:spark-hive_2.12:jar:3.0.1:provided
[INFO] |  \- org.apache.hive:hive-common:jar:2.3.7:provided
[INFO] |     \- (com.fasterxml.jackson.core:jackson-databind:jar:2.6.5:provided - omitted for conflict with 2.6.3)
[INFO] \- org.json4s:json4s-jackson_2.12:jar:4.1.0-M2:provided
[INFO]    \- org.json4s:json4s-jackson-core_2.12:jar:4.1.0-M2:provided
[INFO]       \- (com.fasterxml.jackson.core:jackson-databind:jar:2.13.4.2:provided - omitted for conflict with 2.6.3)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.620 s
[INFO] Finished at: 2023-03-23T10:20:04+08:00
[INFO] ------------------------------------------------------------------------

Process finished with exit code 0

找到相关jar包的pom引入处(如果父pom中用了 dependencyManagement,直接再父pom中修改,就可以影响所有子pom了),加上:

                <exclusions>
                    <exclusion>
                        <groupId>com.fasterxml.jackson.core</groupId>
                        <artifactId>jackson-databind</artifactId>
                    </exclusion>
                </exclusions>

例如:

<dependency>
                <groupId>org.apache.spark</groupId>
                <artifactId>spark-hive_2.12</artifactId>
                <version>${spark.version}</version>
                <scope>${fi.scope}</scope>
                <exclusions>
                    <exclusion>
                        <groupId>com.fasterxml.jackson.core</groupId>
                        <artifactId>jackson-databind</artifactId>
                    </exclusion>
                </exclusions>
</dependency>

加完后再执行命令可以看到,没有冲突了:

[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ sr-flow-api ---
[INFO] com.huawei.ccloud.sparkle.search:sr-flow-api:jar:1.0.0-SNAPSHOT
[INFO] \- org.json4s:json4s-jackson_2.12:jar:4.1.0-M2:provided
[INFO]    \- org.json4s:json4s-jackson-core_2.12:jar:4.1.0-M2:provided
[INFO]       \- com.fasterxml.jackson.core:jackson-databind:jar:2.13.4.2:provided
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  7.871 s
[INFO] Finished at: 2023-03-23T10:25:45+08:00
[INFO] ------------------------------------------------------------------------

Process finished with exit code 0

若mvn命令跑出来的结果已经更新,但是是idea没有更新:
报错NoClassDefFoundError: com/fasterxml/jackson/core/json/JsonWriteFeature; omitted for conflict with,IDEA,Error,json,spark,scala
则File->Invalidate caches 清除缓存重启即可:
报错NoClassDefFoundError: com/fasterxml/jackson/core/json/JsonWriteFeature; omitted for conflict with,IDEA,Error,json,spark,scala

实际上,要想解决java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/json/JsonWriteFeature问题,还没结束,还要将以下两个jar包冲突排除,用一样的方法:

                <exclusions>
                    <exclusion>
                        <groupId>com.fasterxml.jackson.core</groupId>
                        <artifactId>jackson-databind</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>com.fasterxml.jackson.core</groupId>
                        <artifactId>jackson-core</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>com.fasterxml.jackson.core</groupId>
                        <artifactId>jackson-annotations</artifactId>
                    </exclusion>
                </exclusions>

报错NoClassDefFoundError: com/fasterxml/jackson/core/json/JsonWriteFeature; omitted for conflict with,IDEA,Error,json,spark,scala文章来源地址https://www.toymoban.com/news/detail-737947.html

到了这里,关于报错NoClassDefFoundError: com/fasterxml/jackson/core/json/JsonWriteFeature; omitted for conflict with的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包