当前位置: 首页 > news >正文

spring一个错误修正

spring一个错误修正

2026-06-09 19:36:51[559] [4309] WARN o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext - Exception encountered during context initialization -
cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'roleBaseService':
Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException:
Bean named 'roleMapper' is expected to be of type 'com.xy.game.app.role.mapper.GameRoleMapper' but was actually of type 'com.sun.proxy.$Proxy110'

***************************
APPLICATION FAILED TO START
***************************

Description:

The bean 'roleMapper' could not be injected as a 'com.xy.game.app.role.mapper.GameRoleMapper' because it is a JDK dynamic proxy that implements:
com.baomidou.mybatisplus.core.mapper.BaseMapper

public interface GameRoleMapper extends BaseMapper<RoleEntity>
{
}

 

RoleBaseService.java中定义了
@Resource
private GameRoleMapper roleMapper;
roleMapper改为gameRoleMapper就可以了
@Resource
private GameRoleMapper gameRoleMapper;