返回顶部
首页 > 资讯 > 后端开发 > JAVA >启动项目报错:The bean ‘XXXXMapper‘ could not be injected because it is a JDK dynamic proxy
  • 586
分享到

启动项目报错:The bean ‘XXXXMapper‘ could not be injected because it is a JDK dynamic proxy

java 2023-09-16 11:09:45 586人浏览 薄情痞子
摘要

Description: The bean 'studentMapper' could not be injected because it is a jdk dynamic proxy The bean is of type 'com.s

Description:

The bean 'studentMapper' could not be injected because it is a jdk dynamic proxy

The bean is of type 'com.sun.proxy.$Proxy250' and implements:
    com.xinwei.learning.mapper.StudentMapper

Expected a bean of type 'com.xinwei.learning.manager.education.mapper.TeachinGClassStudentMapper' which implements:
    com.xinwei.common.db.mapper.BaseMapperX


Action:

Consider injecting the bean as one of its interfaces or forcing the use of CGLib-based proxies by setting proxyTargetClass=true on @EnableAsync and/or @EnableCaching.
 

报错原因:

是因为我们用了注解@Resource 注入接口或者映射文件,然后多个地方注入后的别名不一致,就会出现这个问题。

解决办法:

每个注入接口或者映射文件的地方,统一取同一个别名,如下:

classStudentMapper
    @Resource    private TeachingClassStudentMapper classStudentMapper;

或者运用@Autowired注解注入即可,每个类注入后的别名可以不一样

    @Autowired    private TeachingClassStudentMapper classStudentMapper;

来源地址:https://blog.csdn.net/qq_39086936/article/details/131600869

--结束END--

本文标题: 启动项目报错:The bean ‘XXXXMapper‘ could not be injected because it is a JDK dynamic proxy

本文链接: https://lsjlt.com/news/409890.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作