SpringBoot+Mybatis常见错误(一): Invalid bound statement (not found)

工程搭建目录:

@Controller
@RequestMapping(value="/api")
public class TokenController

public interface TokenService

@Service
public class TokenServiceImpl implements TokenService

@Repository
public interface TokenMapper

TokenMapper.xml

当启动工程后,请求Controller报错误信息的主要内容如下:

Invalid bound statement (not found): com.tui.cibs.api.services.TokenService.getTokenByAppId]

该错误的意思是,Spring把TokenService当作Mapper接口注入了,正确情况下,应该只应去注入Repository即Mapper所在的目录,正确的修改如下(在SpringBoot主启动类中添加或修改):

@MapperScan(basePackages="com.ltcui.cibs.**.mapper") // 仅扫描*.mapper目录下的

 

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章