Unsatisfied dependency expressed through field ‘baseMapper‘;
BUG描述
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'roleServiceImpl': Unsatisfied dependency expressed through field 'baseMapper'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'cn.imyjs.mp.mapper.RoleMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
在使用mybatis-plus的时候遇到这个报错,出现这个报错的原因主要有以下两点:
BUG解决
1.导入的依赖的问题:
注意在使用spring boot整合mybatis-plus时导入的是如下依赖:
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.1</version>
</dependency>
而不是:
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus</artifactId>
<version>3.5.1</version>
</dependency>
2.注解问题
在mapper文件中的类中加入@Mapper注解
@Mapper
public interface RoleMapper extends BaseMapper<Role> {
}
service接口实现类中加入@Service注解
@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService {
}
微信关注
阅读剩余
版权声明:
作者:理想
链接:https://www.imyjs.cn/archives/725
文章版权归作者所有,未经允许请勿转载。
THE END