0%

Error creating bean with name ‘httpPutFormContentFilter‘问题解决

记录一次上传代码到服务器后出现Error creating bean with name ‘httpPutFormContentFilter‘问题的解决方案

问题描述

前几天在处理一个新的业务时复用了以前一个老项目的代码框架进行修改,但是在上传代码到测试环境运行时报了以下错误:

1
2
Error starting Tomcat context. Exception: org.springframework.beans.factory.BeanCreationException. 
Message: Error creating bean with name 'httpPutFormContentFilter' defined in class path resource

我一看是Tomcat相关的问题,就去检查了代码中是否接口访问路径有冲突,当时找到了有两个Controller的访问url重复了,以为是这个问题,但是重新部署后问题也没有解决;

问题解决

通过去Stack Overflow查找发现可能是以下两个原因导致的:

  1. 启动类未加@SpringBootApplication;
  2. 引入依赖出错,或者重复引入依赖;

最后我发现我的项目是在引入了spring-boot-starter-web的同时,又引入了spring-web重复依赖导致的,注释掉spring-web依赖后问题顺利解决;

1
2
3
4
5
6
7
8
<!--        <dependency>-->
<!-- <groupId>org.springframework</groupId>-->
<!-- <artifactId>spring-web</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>