SSH框架用注解整合时报错 Unable to instantiate Action, com.eng.action.FrameAction

  • Post author:
  • Post category:其他


具体报错:

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框架。



版权声明:本文为u013931282原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。