1024programmer Blog SSM error: bean injection failed_Why does the backend write paging will report a bean error_Kakahushuo Blog

SSM error: bean injection failed_Why does the backend write paging will report a bean error_Kakahushuo Blog

class=”markdown_views prism-atom-one-dark”>

Error message:

 Error creating bean with name 'atUserAction': Unsatisfied dependency expressed through field 'atUserService';
  nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type
  'cn.overloard.service.AtUserService' available: expected at least 1 bean which qualifies as autowire candidate.
  Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
 

This error means that the bean injection failed, we can find it in the order of container initialization.
1. Look at web.xml first. There is a listener configured here, especially classpath: This parameter must be checked to see if it matches the name of the configuration file.

 <listener
         listener-classorg.springframework.web.context.ContextLoaderListener</listener  -class
     </listener
     context-param
         param-namecontextConfigLocation</param-name
         param-valueclasspath:applicationContext-*.xml</param-value  
     </context-param>  
 

2. Check the applicationContext.xml and springMVC.xml files. In general projects, it is injected by package scanning, so check if the
scanned package path is correct.

applicationContext.xml

 context:component-scan base-package="cn.overloard">
         context:exclude-filter   type="annotation"
                                 expression="org.springframework.stereotype.Controller" />
     </context:component-  scan
 

springMVC.xml


   context:component-scan   base-package=  "cn.overloard" use-default-filters="false"
       
       context:include-filter   type="annotation" expression="org.springframework.stereotype.Controller"/>
   </context:component-  scan
 

3. Check if there is any annotation in the class that you forgot to write
Generally, one of these @Controller, @Service, @Repository, @Component annotations
Such as:

@Service
 public class AtUserServiceImpl implements AtUserService{
     }

 @Controller
 public class AtUserAction {
     }

 

4. If you configure beans through xml. You need to check whether the id and class are correct.

bean id="persion" class="cn.overloard.utils.Persion"/>
 

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/ssm-error-bean-injection-failed_why-does-the-backend-write-paging-will-report-a-bean-error_kakahushuo-blog/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索