我用SSH进行开发,使用SPRING代理STRUTS,我想进行HIBERNATE的事务管理,如果我显性进行事务管理,可以成功,但是在SPRING中配置事务就会出现异常,说无法创建bean。就是说我把事务管理的这段代码删除掉就异常了
我的SPRING配置如下
PROPAGATION_REQUIRED
myservice
interceptor2
异常如下:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name '/insert' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy3] to required type [dao.MyServiceImp] for property 'myservice'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy3] to required type [dao.MyServiceImp] for property 'myservice': no matching editors or conversion strategy found
Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessException details (1) are:
PropertyAccessException 1:
org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy3] to required type [dao.MyServiceImp] for property 'myservice'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy3] to required type [dao.MyServiceImp] for property 'myservice': no matching editors or conversion strategy found
Caused by: java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy3] to required type [dao.MyServiceImp] for property 'myservice': no matching editors or conversion strategy found
我的理解是无法进行类型转化导致无法创建/insert找个bean,但是我没有进行类型转换啊,而且我不加事务处理的时候运行都很正常
从dao.MyServiceImp抽象一个接口dao.IMyService,
修改com.yourcompany.struts.action.InsertAction的下列方法:
[code="java"]
public void setMyservice(IMyService service){
//your code
}
[/code]
因为BeanNameAutoProxyCreator创建的是动态代理,必须在接口上创建。
[color=orange][align=center][size=medium]享受下音乐吧[/size][/align][/color]
[flash=500,300]http://www.bgfl.org/bgfl/custom/resources_ftp/client_ftp/ks2/music/pda_virtual_keyboard/flash/piano.swf[/flash]