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
java.lang.NoClassDefFoundError: org/apache/commons/collections/Transformer
提问by Ben
I am receiving the following error java.lang.NoClassDefFoundError: org/apache/commons/collections/Transformer
trying to use BeanMap
from 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 cohortStudentData
is a list of beans.
它是从以下代码生成的:BeanMap studentBeanMap = new BeanMap(cohortStudentData.get(row));
wherecohortStudentData
是 bean 列表。
I am using BeanListHandler
from Apache DBUtils to form the list of beans from a database.
我正在使用BeanListHandler
Apache DBUtils 从数据库中形成 bean 列表。
I understand from thisand thisbug report that BeanMap
is 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 框架的错误报告中了解到。但是,我已将所有相关库导入到我的项目和类中,如下所示:
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>