项目启动的时候,找不到mapper文件
Java
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所在的文件夹
java
@SpringBootApplication
@MapperScan(basePackages = "com.zb.mapper")
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}