具体报错:
Unable to instantiate Action,com.eng.action.FrameAction, defined for’centerFrame’ in namespace ‘/frame’Error creating bean with name’com.eng.action.FrameAction’: Autowiring of fields failed; nested exception isorg.springframework.beans.factory.BeanCreationException: Could not autowirefield: private com.eng.service.WelnewsServicecom.eng.action.FrameAction.welnewsservice; nested exception isorg.springframework.beans.factory.NoSuchBeanDefinitionException: No unique beanof type [com.eng.service.WelnewsService] is defined: Unsatisfied dependency oftype [interface com.eng.service.WelnewsService]: expected at least 1 matchingbean
可能的原因:action、service、dao类的上方忘记加注解
解决办法:
action、service、dao类的上方忘记加注解,分别应该加:
@Controller
@Scope
(
“prototype”
);
@Service
;
@Repository
;其中dao和service层的注解只在impl实现类上加。Action层的注解相当于把action托管给Spring框架。