项目中遇到 no matching editors or conversion strategy found

来源:互联网 发布:应届生java程序员面试 编辑:程序博客网 时间:2024/05/21 21:55


控制台报错:


Unable to instantiate Action, com.anyuan.erp.pa.leagueworking.onlinetrain.web.OnlineTrainAction,  defined for 'frame' in namespace '/leagueworking/onlinetrain'Failed to convert property value of type [com.sun.proxy.$Proxy40] to required type [com.anyuan.erp.pa.leagueworking.onlinetrain.service.OnlineTrainService] for property 'onlineTrainService'; nested exception is java.lang.IllegalArgumentException:Cannot convert value of type [com.sun.proxy.$Proxy40] to required type [com.anyuan.erp.pa.leagueworking.onlinetrain.service.OnlineTrainService] for property 'onlineTrainService':no matching editors or conversion strategy found - action - file:/E:/workspace/AYERP_PA/target/classes/pa/struts/leagueworking/onlinetrain/struts-onlineTrain.xml:7:107



        在做项目时自己的实现类OnlineTrainServiceImpl需要去继承框架里的一个抽象类,大意忘了去实现自己的接口OnlineTrainService,

等完成代码,Spring以及Struts配置文件后,去运行项目,结果页面报错。控制台出现了上面的一堆错误,起初我以为是配置文件里的action的namespace以及报名写错了,仔细对比发现没有什么问题,在网上搜,才发现报错的原因是没有实现类实现错了接口,或者没有实现接口,才会导致 嵌套异常为java.lang.IllegalArgumentException:无法将属性'onlineTrainService'的类型[com.sun.proxy。$ Proxy40]的值转换为必需类型[com.anyuan.erp.pa.leagueworking.onlinetrain.service.OnlineTrainService]: 找不到匹配的编辑器或转换策略 - action - file:/ 

Spring配置文件如下:

<!--在线培训记录-->
<bean id="onlineTrainService" class="com.anyuan.erp.pa.leagueworking.onlinetrain.service.impl.OnlineTrainServiceImpl" />

修改自己的实现类实现自己所写的interface之后,就不会报错了;


其原因我觉得可能是:


       Spring注入的是接口,关联的是实现类。 这里注入了实现类,所以报异常了。正如我的配置文件bean id="onlineTrainService"  但是却关联的是实现类,而我的实现类有没有去实现自己的接口,所以才会报错。

0 0
原创粉丝点击