1、问题描述:找不到Mapper文件
1.1、原因:
没有扫描到相应的包,导致出现错误
APPLICATION FAILED TO START
***************************
Description:
Field loginService in com.ck.shirodemo.controller.LoginController required a bean of type 'com.ck.shirodemo.dao.SysUserMapper' 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.ck.shirodemo.dao.SysUserMapper' in your configuration.
Process finished with exit code 0
1.2、解决办法:
在启动类上加上 @MapperScan("扫描的包")
,一般是扫描dao层文件夹即可,具体看项目搭建架构。
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
@MapperScan("com.ck.shirodemo.dao")
public class ShiroDemoApplication {
public static void main(String[] args) {
SpringApplication.run(ShiroDemoApplication.class, args);
}
}