完整报错如下:
Error creating bean with name 'userServiceImpl': Unsatisfied dependency expressed through field 'baseMapper'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com******zkbms.mapper. UserMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
提示我找不到UserMapper,错误在mapper映射文件中, 我的是类名起别名造成的,改成用全路径就可以了。
没改前:
改之后:
改完后项目可以运行。
【记录下另一种方法】
之前我使用 别名 报错的原因是
没有在yml进行配置,在yml进行配置之后,也可以正常运行。
1.配置别名 @Alias(“User”)
@Alias("User")
public class User implements Serializable {
2.在yml中进行配置
mybatis-plus:
type-aliases-package: com.******.zkbms.entity
3.使用
4.启动测试
总结: 报错的原因还是因为 mybatis-plus使用不熟练,加油吧!