Description:
Field albumMapper in com.changgou.goods.service.impl.AlbumServiceImpl required a bean of type 'com.changgou.goods.dao.AlbumMapper' 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.changgou.goods.dao.AlbumMapper' in your configuration.
Process finished with exit code 1
tk通用mapper的使用,但扫描不到mapper包
解决:
要在application里添加tk.mybatis包下的注解@MapperScan扫描tk的mapper包(核心内容)!!!
@MapperScan(basePackages = {"com.changgou.goods.dao"})//开启通用Mapper的包扫描
package com.changgou.goods.controller;
import com.changgou.goods.pojo.Album;
import com.changgou.goods.service.AlbumService;
import com.github.pagehelper.PageInfo;
import entity.Result;
import entity.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import tk.mybatis.spring.annotation.MapperScan;
import java.util.List;
/****
* @Author:shenkunlin
* @Description:
* @Date 2019/6/14 0:18
*****/
@RestController
@RequestMapping("/album")
@CrossOrigin
@MapperScan(basePackages = {"com.changgou.goods.dao"})//开启通用Mapper的包扫描
public class AlbumController {
@Autowired
private AlbumService albumService;