. lang。NoClassDefFoundError:org/apache/commons/fileupload/FileItemFactory

时间:2022-11-06 15:39:55

I am trying a simple example of file upload in spring MVC using maven and I follwed this tutorial.

我正在尝试使用maven在spring MVC中上传文件的一个简单示例,并在本教程中完成。

But I am getting this error

但是我得到了这个错误。

java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory

I also included the dependencies in pom.xml

我还在py .xml中包含了依赖项

<!-- Apache Commons Upload --> 
<dependency>
    <groupId>commons-io</groupId>
    <artifactId>commons-io</artifactId>
    <version>1.3.2</version>
</dependency>

also in dispatcher-servlet.xml

也在dispatcher-servlet.xml

<!-- Configure the multipart resolver -->
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
    <!-- one of the properties available; the maximum file size in bytes -->
    <property name="maxUploadSize" value="100000"/>
</bean> 

So, can you help me where I am going wrong.

所以,你能帮我解决我的问题吗?

Thanks in advance.

提前谢谢。

1 个解决方案

#1


108  

You need to add commons-fileupload

您需要添加common -fileupload

add this to your POM

把这个加到POM中

<dependency>
   <groupId>commons-fileupload</groupId>
   <artifactId>commons-fileupload</artifactId>
   <version>1.2.1</version> <!-- makesure correct version here -->
</dependency>

#1


108  

You need to add commons-fileupload

您需要添加common -fileupload

add this to your POM

把这个加到POM中

<dependency>
   <groupId>commons-fileupload</groupId>
   <artifactId>commons-fileupload</artifactId>
   <version>1.2.1</version> <!-- makesure correct version here -->
</dependency>