admin管理员组

文章数量:1530050

这是我用Spring整合Mybatis并配置事务时,获取bean时得到的一个错误

Bean named 'xxx' is expected to be of type 'xxx' but was actually of type 'com.sun.proxy.$Proxy19'

这个就是我的Service层

这个是我获取bean的代码,如果第二个参数是CourseService.class的话就没有什么问题,但是因为我在CourseServiceImpl中加了几个方法所以需要用到它的实现类,所以必须获取CourseServiceImpl

CourseServiceImpl courseService = applicationContext.getBean("courseService",CourseServiceImpl.class);

解决方法:
applicationContext.xml里面修改代理模式为proxy-target-class="true"

<tx:annotation-driven transaction-manager="dataSourceTransactionManager" proxy-target-class="true" />

本文标签: 报错beannamedSpring