zoukankan      html  css  js  c++  java
  • service类上要有标注,否则会报下面的错。缺少唯一的一个serivce bean。

    type Exception report

    message

    description The server encountered an internal error () that prevented it from fulfilling this request.

    exception

    Unable to instantiate Action, orgMgrAction,  defined for 'orgMgr' in namespace '/customer'Error creating bean with name 'orgMgrAction': Autowiring of fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.crm.service.personnel.PersonnelService org.crm.action.customer.orgMgrAction.personnelService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [org.crm.service.personnel.PersonnelService] is defined: Unsatisfied dependency of type [class org.crm.service.personnel.PersonnelService]: expected at least 1 matching bean
    	com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:306)
    	com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:387)
    	com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:186)
    	org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
    

    root cause

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'orgMgrAction': Autowiring of fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.crm.service.personnel.PersonnelService org.crm.action.customer.orgMgrAction.personnelService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [org.crm.service.personnel.PersonnelService] is defined: Unsatisfied dependency of type [class org.crm.service.personnel.PersonnelService]: expected at least 1 matching bean
    	org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:243)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:959)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
    	java.security.AccessController.doPrivileged(Native Method)
    

    org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.crm.service.personnel.PersonnelService org.crm.action.customer.orgMgrAction.personnelService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [org.crm.service.personnel.PersonnelService] is defined: Unsatisfied dependency of type [class org.crm.service.personnel.PersonnelService]: expected at least 1 matching bean
    org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:435)
    org.springframework.beans.factory.annotation.InjectionMetadata.injectFields(InjectionMetadata.java:105)

    org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [org.crm.service.personnel.PersonnelService] is defined: Unsatisfied dependency of type [class org.crm.service.personnel.PersonnelService]: expected at least 1 matching bean
    org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:613)
    org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor

    解决办法: 在service类的前面加上标注。

    @Service("personnelService")
    @Transactional
    public class PersonnelService {

    。。。。。。。。

    }

  • 相关阅读:
    [ Docker ] 基础安装使用及架构
    [ Docker ] 基础概念
    Nginx
    ELK
    SVN + Jenkins 构建自动部署
    Zabbix
    ELK
    ELK 部署文档
    vue.js在visual studio 2017下的安装
    vue.js是什么
  • 原文地址:https://www.cnblogs.com/guanghuiqq/p/2643820.html
Copyright © 2011-2022 走看看