spring注入一定得接口吗?

spring注入一定得接口吗?

今日在类中写上
@Autowired
private AskQuestionServiceImp  service;


竟然报错。
Unable to instantiate Action, org.java1995.askchannel.admin.action.QuestionAction,  defined for 'question' in namespace '/admin'Error creating bean with name 'org.java1995.askchannel.admin.action.QuestionAction': Autowiring of fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.java1995.askchannel.admin.service.imp.QuestionAdminServiceImp org.java1995.askchannel.admin.action.QuestionAction.questionAdminService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [org.java1995.askchannel.admin.service.imp.QuestionAdminServiceImp] is defined: Unsatisfied dependency of type [class org.java1995.askchannel.admin.service.imp.QuestionAdminServiceImp]: expected at least 1 matching bean
	


很是奇怪了。

你可能感兴趣的:(java,spring,bean)