java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory
I am trying a simple example of file upload in spring MVC using maven and I follwed this tutorial.
But I am getting this error
java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory
I also included the dependencies in pom.xml
<!-- Apache Commons Upload -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>
also in 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>
Wh开发者_运维知识库ere I am going wrong?
You need to add commons-fileupload
add this to your POM
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2.1</version> <!-- makesure correct version here -->
</dependency>
For the security use version 1.4 :
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.4</version>
</dependency>
Check : https://mvnrepository.com/artifact/commons-fileupload/commons-fileupload
精彩评论