Could not autowire field: private javax.servlet.http.HttpServletRequest

Posted 緈諨の約錠

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Could not autowire field: private javax.servlet.http.HttpServletRequest相关的知识,希望对你有一定的参考价值。

在写单元测试类的时候,报错,废了很大劲才给调试好,给大家分享下。

 

完整错误如下:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name \'buskjjlzjwyhpsController\': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.servlet.http.HttpServletRequest com.yunhwa.business.controller.buskjjlzjwyhpsController.request; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [javax.servlet.http.HttpServletRequest] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

 最后加入该注解完美解决

 

以上是关于Could not autowire field: private javax.servlet.http.HttpServletRequest的主要内容,如果未能解决你的问题,请参考以下文章

跪求大神:Could not autowire field: private com.mvc.service.StudentService com.mvc.controller.Stud

Could not autowire field: private java.lang.Integer com.taotao.sso.service.impl.UserServiceImpl.SSO_

bugidea无法使用@Autowired , 提示could not autowire

IDEA mybatis 在service无法使用@Autowired , could not autowire

spring boot2 - Could not autowire报错

idea报错could not autowired .但是可以正常运行