`

org.springframework.beans.factory.BeanNotOfRequiredTypeException

 
阅读更多
struts1中
http://localhost:8089/bupt_oa/notes.do?actions=list请求报错!
动态代理访问bean为:/notes时,因为没有转化为实际处理的Action,所以报错




1.org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named "" must be of type [org.apache.struts.action.Action]


情况一、
application-config-core.xml:
	<plug-in
		className="org.springframework.web.struts.ContextLoaderPlugIn">
		<set-property property="contextConfigLocation"
			value="/WEB-INF/classes/spring/core/applicationContext-struts.xml" />
	</plug-in>	


applicationContext-struts.xml
<!-- add by mohy 邮件 信息 便签 -->
<import resource="classpath*:spring/bupt/notes/applicationContext-notes-action.xml"/>




情况二、
Action类没有继承Action类及其子类




2.
org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'userService' must be of type [com.anping.service.impl.UserServiceImpl], but was actually of type [$Proxy15]
错误:
ApplicationContext  ac = new ClassPathXmlApplicationContext("applicationContext.xml");
    UserService service =(UserService) ac.getBean( UserServiceImpl.class);
正确:
ApplicationContext  ac = new ClassPathXmlApplicationContext("applicationContext.xml");
    UserService service =(UserService) ac.getBean( UserService.class);
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics