首页 > spring 注入bean类型不匹配

spring 注入bean类型不匹配

报错SEVERE: Error building bean
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.sendi.console.action.MainAction': Unsatisfied dependency expressed through bean property 'session': : Error creating bean with name 'activityAction': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.sendi.console.service.ActivityService com.sendi.console.action.ActivityAction.activityService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.sendi.console.service.ActivityService] found for dependency: expected a

查了是注入bean类型不匹配,要哪里和哪匹配?


错误很明显com.sendi.console.service.ActivityService,找下有没有注入这个类型的


Class

import com.test.bean.ServiceBean;
public class Action{
      @Autowired
      private ServiceBean serviceBean;
}

spring.xml

<bean id="serviceBean" class="com.test.bean.ServiceBean"/>

这里的两个serviceBean需要同一种类型


名称错误了,无法注入

【热门文章】
【热门文章】