idea出现The injection point has the following annotations: - @org.springframework.beans.factory...

小鱼儿 2022-12-29 00:21 112阅读 0赞
  • 出现下方错误请查看启动类:XXXApplication 是否扫描到mapper映射文件,声明eclipse和idea不一样,这里eclipse可以跑通,idea中不行


    1. APPLICATION FAILED TO START
    2. ***************************
    3. Description:
    4. Field chapterDao in cn.yixue.service.ChapterServiceImp required a bean of type 'cn.yixue.dao.ChapterMapper' that could not be found.
    5. The injection point has the following annotations:
    6. - @org.springframework.beans.factory.annotation.Autowired(required=true)
  1. Action:
  2. Consider defining a bean of type 'cn.yixue.dao.ChapterMapper' in your configuration.
  3. 以上提取出有用的信息:required a bean of type 'xxxx' that could not be found.
  4. 代表bean没注入,从bean注入寻找方向,有的人会说我用@Autowired之类的种种,但没扫到,好吧~

解决方法:

  1. 在相应的mapper类中加@Mapper标注让springboot根据标注去将mapper注入

    @Mapper
    public interface ChapterMapper {

    1. ......

    }

  2. 启动类加@MapperScan(value = "cn.yixue.video.dao") value 后的包一定要对应到mapper类对应的地方,比如我的mapper在dao下,就是cn.yixue.video.dao

    @SpringBootApplication
    @MapperScan(value = “cn.yixue.video.dao”)
    @EnableDiscoveryClient
    public class YixueVideoApplication {

    1. public static void main(String[] args) {
    2. SpringApplication.run(YixueVideoApplication.class, args);
    3. }

    }

以下大佬给我很大的启发,灰常感谢

https://www.cnblogs.com/cxylff/p/10969375.html

发表评论

表情:
评论列表 (有 0 条评论,112人围观)

还没有评论,来说两句吧...

相关阅读