问题
在运行一个新项目的时候
报错
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'employeeController': Unsatisfied dependency expressed through field 'employeeService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'employeeServiceImpl': Unsatisfied dependency expressed through field 'baseMapper'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.xiaosheng.mapper.EmployeeMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
controller层
@Slf4j
@RestController
@RequestMapping("/employee")
public class EmployeeController {
@Autowired
private EmployeeService employeeService;
/**
* 登录
* @param req
* @param employee
* @return
*/
@PostMapping("/login")
public R<Employee> login(HttpServletRequest req, @RequestBody Employee employee){
return
mapper层
public interface EmployeeMapper extends BaseMapper<Employee> {
}
service
public interface EmployeeService extends IService<Employee> {
}
serviceimpl
/**
* mybatis 规范,继承他的父类,实现他的父接口
*/
@Service
public class EmployeeServiceImpl extends ServiceImpl<EmployeeMapper, Employee> implements EmployeeService {
}
发现问题
mapper
层没有加mapper
注解
@Mapper
public interface EmployeeMapper extends BaseMapper<Employee> {
}