问题

在运行一个新项目的时候
报错

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> {
}
分类: java

站点统计

  • 文章总数:315 篇
  • 分类总数:20 个
  • 标签总数:193 个
  • 运行天数:1127 天
  • 访问总数:12666 人次

浙公网安备33011302000604

辽ICP备20003309号