概述
报错信息
‘org.springframework.web.multipart.support.StandardMultipartHttpServletRequestStandardMultipartFile′torequiredtype′org.springframework.web.multipart.commons.CommonsMultipartFile′;nestedexceptionisjava.lang.IllegalStateException:Cannotconvertvalueoftype′org.springframework.web.multipart.support.StandardMultipartHttpServletRequestStandardMultipartFile′torequiredtype′org.springframework.web.multipart.commons.CommonsMultipartFile′;nestedexceptionisjava.lang.IllegalStateException:Cannotconvertvalueoftype′org.springframework.web.multipart.support.StandardMultipartHttpServletRequestStandardMultipartFile’ to required type ‘org.springframework.web.multipart.commons.CommonsMultipartFile’: no matching editors or conversion strategy found
解决方案:
方案1.直接将CommonsMutipartFile转为MutipartFile
方案2.如果继续使用CommonsMutipartFile,则在项目添加配置类
@Bean(name = "multipartResolver") public CommonsMultipartResolver getCommonsMultipartResolver() { CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(); multipartResolver.setMaxUploadSize(20971520); multipartResolver.setMaxInMemorySize(1048576); return multipartResolver; }
同时在spring boot的applications文件中加入
multipart.enabled=true
最后
以上就是仁爱毛衣为你收集整理的spring boot上传CSV文件 MultiPartFile与CommonsMultiPartFile转换异常的全部内容,希望文章能够帮你解决spring boot上传CSV文件 MultiPartFile与CommonsMultiPartFile转换异常所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复