解决包冲突

博客指出使用Idea运行程序时出现报错,经分析是log4j包冲突所致,解决办法是注释掉父类工程的log4j依赖,同时提醒在Maven工程导入依赖时要注意父类和子类间的包冲突问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

运行程序时,idea报错如下:

ERROR StatusLogger No Log4j 2 configuration file found. Using default configuration (logging only errors to the console), or user programmatically provided configurations. Set system property 'log4j2.debug' to show Log4j 2 internal initialization logging. See https://logging.apache.org/log4j/2.x/manual/configuration.html for instructions on how to configure Log4j 2
Exception in thread "main" java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
	at org.apache.commons.logging.impl.SLF4JLocationAwareLog.debug(SLF4JLocationAwareLog.java:131)
	at org.apache.hadoop.metrics2.impl.MetricsSystemImpl.register(MetricsSystemImpl.java:232)
	at org.apache.hadoop.metrics2.MetricsSystem.register(MetricsSystem.java:60)
	at org.apache.hadoop.security.UserGroupInformation$UgiMetrics.create(UserGroupInformation.java:121)
	at org.apache.hadoop.security.UserGroupInformation.<clinit>(UserGroupInformation.java:237)
	at org.apache.spark.util.Utils$$anonfun$getCurrentUserName$1.apply(Utils.scala:2406)
	at org.apache.spark.util.Utils$$anonfun$getCurrentUserName$1.apply(Utils.scala:2406)
	at scala.Option.getOrElse(Option.scala:121)
	at org.apache.spark.util.Utils$.getCurrentUserName(Utils.scala:2406)
	at org.apache.spark.SparkContext.<init>(SparkContext.scala:295)
	at com.air.antispider.stream.dataprocess.launch.DataProcessLauncher$.main(DataProcessLauncher.scala:20)
	at com.air.antispider.stream.dataprocess.launch.DataProcessLauncher.main(DataProcessLauncher.scala)

报错信息很明显,是log4j的包冲突了,注释掉父类工程的log4j依赖即可。
注意:maven工程导入依赖的时候注意父类和子类之间的包冲突。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值