<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>5.0.5.RELEASE</version>
<scope>compile</scope>
</dependency>
import org.springframework.web.multipart.MultipartFile;
import org.apache.http.entity.ContentType;
MultipartFile multipartFile = new MockMultipartFile(name,name,ContentType.APPLICATION_OCTET_STREAM.toString(),acceptFile);
地址:https://www.leftso.com/article/607.html