admin管理员组文章数量:1571758
问题描述:
报错:
启动报错=== Error creating bean with name ‘carouselServiceImpl’: Unsatisfied dependency expressed through field ‘carouselMapper’; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘cn.xyz.mianshi.mapper.CarouselMapper’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
报错翻译:
创建名称为’carouselServiceImpl’的bean时出错:通过字段’carouselMapper’表示不满意的依赖关系;嵌套异常是org.springframework.beans.factory.NoSuchBeanDefinitionException:没有类型为’cn.xyz.mianshi.mapper的合格bean。CarouselMapper可用:预计至少有1个bean符合自动候选资格。依赖注解:{@org.springframework.beans.factory.annotation.Autowired(required=true)}
报错原因
1.首先检查你的实体类注解是否齐全
@Data
@NoArgsConstructor
@AllArgsConstructor
2.检查你的mapper/dao层注解是否存在
@Mapper(@Repository)两个随便一个都可以
3.检查你的service层注解是否存在
@Service(@Repository)两个随便一个都可以
3.1检查你的service实现类
@Autowired是否注入mapper/dao层
4.检查你的控制器是注解是否存在
@RestController
4.1检查你的controller类中
@Autowired是否注入service层
如果上述注解没有问题,还报错的话,请看下面:
解决方案
我随便找一个类拿来演示:
1.首先看你的service层注入的mapper/dao
private CarouselMapper carouselMapper;
改成下面这种(两个选择其中一个就行):
private CarouselMapper carouselMapper;
@Autowired
public void CarouselMapper (){}
或者
@Autowired
private CarouselMapper carouselMapper;
public void CarouselMapper (){}
2.在看你的controler当中注入的service
private RedirectLinkService redirectLinkService;
改成下面这种情况(两个选择其中一个就行):
private RedirectLinkService redirectLinkService;
@Autowired
public void redirectLinkService(){}
或者
@Autowired
private RedirectLinkService redirectLinkService;
public void redirectLinkService(){}
这个就可以了,启动类就可以正常的启动起来!!!希望可以帮助各位!!!
注意
如过这种方法使用了还是不行,就看你的springboot依赖和mybatis版本依赖是否兼容,适当修改一下版本就行(找到可以互相兼容的类型即可)!!!
本文标签: DependencyUnsatisfiedexpressedxxxmapperField
版权声明:本文标题:Unsatisfied dependency expressed through field ‘XXXMapper‘ 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dianzi/1725804306a1043823.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论