【Bug修复】springMVC解决“Error creating bean with name ‘multipartResolver‘“问题

multipartResolver:文件上传解析

问题出现场景:该问题出现在springMVC再上传文件的过程中;

问题解决方案:

首先:
要在spring-servlet-config.xml中添加文件上传解析的bean,这里对上传文件的编码格式和文件大小进行了配置,代码如下:

    <!-- 上传文件拦截,设置最大上传文件大小   10M=10*1024*1024(B)=10485760 bytes -->
    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <property name="defaultEncoding" value="UTF-8"/>
        <property name="maxUploadSize" value="10485760"/>
    </bean>

接着:

出现标题中的报错是应为没有网页文件上传所需要的是 commons-fileupload 包,而网页文件下载所需要的是commons-io 包,但是我们并没有导入这个包,所以在pom文件中添加依赖:

    <dependency>
      <groupId>commons-fileupload</groupId>
      <artifactId>commons-fileupload</artifactId>
      <version>1.3.1</version>
    </dependency>

问题解决!

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
引用 o.s.boot.SpringApplication : Application run failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configurationPropertiesBeans' defined in class path resource [org/springframework/cloud/autoconfigure/ConfigurationPropertiesRebinderAutoConfiguration.class]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [org.springframework.cloud.context.properties.ConfigurationPropertiesBeans from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2 。 引用引起的。 解决这个问题的方法可能有多种,以下是一些可能的解决方法: 1. 检查项目的pom.xml文件中是否添加了正确的依赖,特别是与Spring Cloud相关的依赖。可以尝试根据引用中提供的示例,使用较新版本的依赖替换较旧版本的依赖。 2. 检查项目的配置文件,例如springmvc-config和applicationContext,确保包名没有拼写错误。可以参考引用中提供的示例,确认扫描Service和Controller包的代码是否正确。 3. 检查类路径中是否存在冲突的类。可能存在不同版本的类在项目中引起冲突。可以尝试清理项目的依赖,并确保只有所需的正确版本的类在类路径中。 综上所述,解决创建'resourcesConfig' bean的错误的方法可能包括修复依赖关系,检查包名和配置文件的拼写错误以及解决类路径冲突。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [完美解决Error creating bean with name ‘configurationPropertiesBeans‘ defined in class path ...](https://blog.csdn.net/qq_37669826/article/details/114668031)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [Error creating bean with name的最佳解决方法](https://blog.csdn.net/HYZX_9987/article/details/100764704)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小树ぅ

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值