springboot启动类启动时报如下错误:
Field deptDao in com.springcloud.service.impl.DeptServiceImpl required a bean of type 'com.springcloud.dao.DeptDao' that could not be found.
解决方法如下:
1、在dao层加上@Mapper注解
@Mapper
public interface DeptDao {
public Dept getDeptById(Long id);
}
2、在启动类上加上@MapperScan(“com.springcloud.dao”)注解
@SpringBootApplication
@ComponentScan("com.springcloud.*")
@EnableEurekaClient
@MapperScan("com.springcloud.dao")
public class DeptProvider8001_App {
public static void main(String[] args) {
SpringApplication.run(DeptProvider8001_App.class, args);
}
}
完美解决