首页 > 其他分享 >The bean 'xxxUserMapper' could not be injected because it is a JDK dynamic proxy

The bean 'xxxUserMapper' could not be injected because it is a JDK dynamic proxy

时间:2022-10-31 16:44:29浏览次数:49  
标签:because JDK could bean xxxUserMapper 代码 XxxUserMapper

The bean 'xxxUserMapper' could not be injected because it is a JDK dynamic proxy

原因

Mapper代码当时如下:

public interface XxxUserMapper extends Mapper<XxxUser> {
}

代码进行注入:

@Resource
XxxUserMapper userMapper;

此处出现问题,原因是已经有同名的“userMapper”Bean对象被注入到spring上下文中。

如下:

public interface UserMapper extends Mapper<User> {}

 

解法方式

@Resource
XxxUserMapper xxxUserMapper;

 

比较简单的错误,提交代码前需要在本地拉取最新代码并且运行成功后,再提交代码,或者引入其他Service时使用默认的bean名称,例如XxxUserMapper,引入时默认xxxUserMapper,能有效避免这类问题;

标签:because,JDK,could,bean,xxxUserMapper,代码,XxxUserMapper
From: https://www.cnblogs.com/use-D/p/16844871.html

相关文章