org.springframework.beans.factory.BeanNotOfRequiredTypeException

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


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);
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值