java.lang.NoClassDefFoundError: org/apache/commons/collections4/ListValuedMap

时间:2021-01-14 15:36:03

1、错误描述

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/collections4/ListValuedMap
	at com.you.print.ExcelUtils.replaceModel(ExcelUtils.java:21)
	at com.you.print.TestReplaceExcel.main(TestReplaceExcel.java:28)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.collections4.ListValuedMap
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 2 more

2、错误原因

     由错误提示可知,是缺少有关collections4的jar


3、解决办法

(1)将commons-collections4-4.1.jar复制到lib目录

(2)如果是Maven项目,可以在pom.xml中添加

<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-collections4</artifactId>
    <version>4.1</version>
</dependency>