问题描述
代码如下:
Mapper类
@Mapper
public interface CategoryMapper {
@Select("select * from category_")
List<Category> findAll();
}
Controller类
@Controller
public class CategoryController {
@Autowired
CategoryMapper categoryMapper;
@RequestMapping("listCategory")
public String listCategory(Model m){
List<Category> cs = categoryMapper.findAll();
m.addAttribute("cs",cs);
return "listCategory";
}
}
Could not autowire.No beans of ‘CategoryMapper’ type found.
解决方法
在Mapper类上加@Repository注解
@Mapper
@Repository
public interface CategoryMapper {
//@Select("select * from category_&#