error creating bean with name "" Autowiring of fields failed

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 {

。。。。。。。。

}

时间: 2024-11-03 05:39:36

error creating bean with name "" Autowiring of fields failed的相关文章

Error creating bean with name 'com.you.user.dao.StudentDaoTest': Injection of autowired dependencies

1.错误描述 七月 13, 2014 6:37:41 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions 信息: Loading XML bean definitions from class path resource [applicationContext.xml] 七月 13, 2014 6:37:42 下午 org.springframework.context.anno

Error creating bean with name

今天碰到一个特别奇怪的问题: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ecfCustomerEditService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: C

Error creating bean with name 'memcachedClient'...java.lang.OutOfMemoryError

1,Tomcat启动报错如下: Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'memcachedClient' defined in file [/usr/local/apache-tomcat-6.0.37_6500/webapps/trade_service/WEB-INF/classes/META-INF/spring/springCont

Error creating bean with name 'menuController': Injection of autowired dependency……

出现了一大串错误 Error creating bean with name 'userController': Injection of autowired dependencies failed..... 查了代码后发现,原来是在UserServiceImpl中忘了写一句话@Service("userService"),以至于因此导致一系列错误. 在控制层调用业务层,必须在业务层先进行注解: @Service("userService"); 然后在控制层注入业务

Java AOP nested exception is java.lang.NoClassDefFoundError: org/aopalliance/aop/Advice || Error creating bean with name 'org.springframework.aop.aspectj.AspectJPointcutAdvisor#0' 两个异常解决办法

贴出applicationContext.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://ww

Error creating bean with name &#39;menuController&#39;: Injection of autowired dependency……

出现了一大串错误,Error creating bean with name 'userController': Injection of autowired dependencies failed..... 查了代码后发现,原来是在UserServiceImpl中忘了写一句话@Service("userService"),以至于因此导致一系列错误. 在控制层调用业务层,必须在业务层先进行注解:@Service("userService"): 然后在控制层注入业务层

Error creating bean with name &#39;sessionFactory&#39; defined in class path resource [applicationContext.xm

报错信息如下: <span style="font-size:24px;">17:18:32,245 ERROR ContextLoader:307 - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resour

Error creating bean with name &#39;org.springframework.validation.beanvalidation.LocalValidatorFactoryBe

Error creating bean with name 'org.springframework.validation.beanvalidation.LocalValidatorFactoryBean#0' Caused by: javax.validation.ValidationException: Unable to create a Configuration, because no Bean Validation provider could be found. Add a pro

Error creating bean with name &#39;org.apache.cxf.binding.soap.customEditorConfigurer&#39;

1.错误描述 2015-09-20 17:08:36 [localhost-startStop-1] WARN org.apache.cxf.bus.spring.BusApplicationContext - Exception encountered during context initialization - cancelling refresh attempt org.springframework.beans.factory.BeanCreationException: Error