spring boot 报 java.lang.NoClassDefFoundError: org/apache/commons/discovery/tools/DiscoverSingleton

白和泽
2023-12-01
  • 起因:spring boot 引入一个web service client 服务,写的定时任务例子,发现执行报错:java.lang.NoClassDefFoundError: org/apache/commons/discovery/tools/DiscoverSingleton。

  • 解决: 缺少相关依赖包,但工程的build path -> configure build path -> libraries 下有commons-discovery 和 commons-logging 包,要移除这两个,不然可能会报:org.apache.commons.discovery.DiscoveryException: No implementation defined for org.apache.commons.logging.LogFactory 错误。
    在pom文件下引入依赖:

<dependency>
    <groupId>commons-discovery</groupId>
    <artifactId>commons-discovery</artifactId>
    <version>0.5</version>
</dependency>
 类似资料: