java.lang.NoClassDefFoundError: org/apache/commons/collections/Transformer

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28778191/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 06:47:53  来源:igfitidea点击:

java.lang.NoClassDefFoundError: org/apache/commons/collections/Transformer

javaruntime-error

提问by Ben

I am receiving the following error java.lang.NoClassDefFoundError: org/apache/commons/collections/Transformertrying to use BeanMapfrom the Apache Commons BeanUtils library.

我在java.lang.NoClassDefFoundError: org/apache/commons/collections/Transformer尝试BeanMap从 Apache Commons BeanUtils 库中使用时收到以下错误。

It is generated from the following code: BeanMap studentBeanMap = new BeanMap(cohortStudentData.get(row));where cohortStudentDatais a list of beans.

它是从以下代码生成的:BeanMap studentBeanMap = new BeanMap(cohortStudentData.get(row));wherecohortStudentData是 bean 列表。

I am using BeanListHandlerfrom Apache DBUtils to form the list of beans from a database.

我正在使用BeanListHandlerApache DBUtils 从数据库中形成 bean 列表。

I understand from thisand thisbug report that BeanMapis dependant on the Apache Collections framework. However, I have imported all relevant libraries into my project and into my class, as you can see below:

我从这个这个BeanMap依赖于 Apache Collections 框架的错误报告中了解到。但是,我已将所有相关库导入到我的项目和类中,如下所示:

External Library List

外部库列表

Import Statements

进口报表

Does anyone know why this might be happening?

有谁知道为什么会发生这种情况?

采纳答案by Ivan Perales M.

I am not really sure, but i think your error is because of jar versions. Lately apache has changed the package of the new versions of their jars because they implement new functionality or something that is not fully backward compatible. For example the jar commons-beanutils-1.9.2.jar depends on commons-collections-3.2.1.jar (according to thissite) and you are using commons-collections-4.4.0.jar. If you are planning using the universe of apache jars, you need to be sure that they are all compatible.

我不太确定,但我认为您的错误是因为 jar 版本。最近 apache 更改了新版本 jar 的包,因为它们实现了新功能或不完全向后兼容的东西。例如,jar commons-beanutils-1.9.2.jar 依赖于 commons-collections-3.2.1.jar(根据网站),而您使用的是 commons-collections-4.4.0.jar。如果您计划使用 apache jar 的世界,您需要确保它们都是兼容的。

回答by zygimantus

Just add this dependency to your project.

只需将此依赖项添加到您的项目中即可。

    <dependency>
        <groupId>commons-collections</groupId>
        <artifactId>commons-collections</artifactId>
        <version>3.2.2</version>
    </dependency>

回答by Manimaran Samuthirapandi

commons-collections4-x.x.jarAdd the library to your classpath and try to run again. It will work.

commons-collections4-xxjar将库添加到您的类路径并尝试再次运行。它会起作用。

Download the library from:https://mvnrepository.com/artifact/org.apache.commons/commons-collections4/4.1

从以下位置下载库:https : //mvnrepository.com/artifact/org.apache.commons/commons-collections4/4.1

回答by thedevd

Adding dependency of version 3.2.1 seems working here

添加版本 3.2.1 的依赖似乎在这里工作

<dependency>
    <groupId>commons-collections</groupId>
    <artifactId>commons-collections</artifactId>
    <version>3.2.1</version>
</dependency>