[英]java.lang.NoClassDefFoundError: org/apache/commons/collections/Transformer
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
试图使用 Apache Commons BeanUtils 库中的BeanMap
。
It is generated from the following code: BeanMap studentBeanMap = new BeanMap(cohortStudentData.get(row));
它由以下代码生成: BeanMap studentBeanMap = new BeanMap(cohortStudentData.get(row));
where cohortStudentData
is a list of beans.其中cohortStudentData
是一个 bean 列表。
I am using BeanListHandler
from Apache DBUtils to form the list of beans from a database.我正在使用 Apache DBUtils 中的BeanListHandler
从数据库中形成 bean 列表。
I understand from this and this bug report that BeanMap
is dependant on the Apache Collections framework.我从这个和这个错误报告中了解到BeanMap
依赖于 Apache Collections 框架。 However, I have imported all relevant libraries into my project and into my class, as you can see below:但是,我已将所有相关库导入到我的项目和类中,如下所示:
Does anyone know why this might be happening?有谁知道为什么会发生这种情况?
I am not really sure, but i think your error is because of jar versions.我不太确定,但我认为您的错误是因为 jar 版本。 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.最近 apache 更改了新版本 jars 的包,因为它们实现了新功能或不完全向后兼容的东西。 For example the jar commons-beanutils-1.9.2.jar depends on commons-collections-3.2.1.jar (according to this site) and you are using commons-collections-4.4.0.jar.例如,jar commons-beanutils-1.9.2.jar 依赖于 commons-collections-3.2.1.jar(根据本网站),而您使用的是 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.如果您计划使用 apache jar 的世界,您需要确保它们都是兼容的。
Just add this dependency to your project.只需将此依赖项添加到您的项目中即可。
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.2</version>
</dependency>
commons-collections4-xxjar Add the library to your classpath and try to run again. commons-collections4-xxjar将库添加到您的类路径并尝试再次运行。 It will work.它会起作用。
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
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>
将 commons-collections-3.2.jar 添加到项目库中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.