maven jar包冲突3种解决方式

初次启动应用,一直报如下错误,起初怀疑引入pandora-boot 版本冲突。

Exception in thread "main" java.lang.NoSuchMethodError: com.taobao.pandora.boot.loader.jmx.mbean.Health.registMBean()V
  at com.taobao.pandora.boot.loader.ReLaunchMainLauncher.launch(ReLaunchMainLauncher.java:39)
  at com.taobao.pandora.boot.PandoraBootstrap.run(PandoraBootstrap.java:41)
  at com.cainiao.wmpooc.OOCApplication.main(OOCApplication.java:27)
  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 com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

Process finished with exit code 1

方式一:通过mvn tree查看

mvn dependency:tree

方式二:通过在启动过程中查看类文件位置

  • 查看Health 具体类路径

查看到具体类路径,辅助分析实际运行路径

或者

Health.class.getProtectionDomain().getCodeSource().getLocation()

方式三:查找类文件

最终:找到引入依赖源头,通过exclusions 进行排除

原文地址:https://www.cnblogs.com/jiangjun-x/p/8195736.html