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类型不匹配,要哪里和哪匹配?
Class
import com.test.bean.ServiceBean;
public class Action{
@Autowired
private ServiceBean serviceBean;
}
spring.xml
<bean id="serviceBean" class="com.test.bean.ServiceBean"/>
这里的两个serviceBean需要同一种类型
这篇关于spring 注入bean类型不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!