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" />
版权声明:本文标题:Spring获取bean报错Bean named ‘xxx‘ is expected to be of type ‘xxx‘ but was actually of type ‘com.sun.pro 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dongtai/1726602384a1077185.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论