首页 > 编程语言 > 详细

spring-boot项目bug总结

时间:2020-01-07 11:43:10      阅读:78      评论:0      收藏:0      [点我收藏+]

1、项目启动的时候,找不到mapper文件

Description:

Field stuMapper in com.zb.service.impl.StuServiceImpl required a bean of type ‘com.zb.mapper.StuMapper‘ that could not be found.

The injection point has the following annotations:
    - @org.springframework.beans.factory.annotation.Autowired(required=true)


Action:

Consider defining a bean of type ‘com.zb.mapper.StuMapper‘ in your configuration.

原因是:mapper没有注入到容器中

解决办法是:在启动文件里,添加@MapperScan(basePackages = "com.zb.mapper"),basePackages 是mapper所在的文件夹

@SpringBootApplication
@MapperScan(basePackages = "com.zb.mapper")
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

 

spring-boot项目bug总结

原文:https://www.cnblogs.com/zhaobao1830/p/12159581.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!