org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.wuhan.it.mapper.PermissionMapper.findAllat org.apache.ibatis.binding.MapperMethod$SqlCommand.(MapperMethod.java:235) ~[mybatis-3.5.7.jar:3.5.7]at org.apache.ibatis.binding.MapperMethod.(MapperMethod.java:53) ~[mybatis-3.5.7.jar:3.5.7]at org.apache.ibatis.binding.MapperProxy.lambda$cachedInvoker$0(MapperProxy.java:108) ~[mybatis-3.5.7.jar:3.5.7]at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660) ~[na:1.8.0_144]at org.apache.ibatis.util.MapUtil.computeIfAbsent(MapUtil.java:36) ~[mybatis-3.5.7.jar:3.5.7]at org.apache.ibatis.binding.MapperProxy.cachedInvoker(MapperProxy.java:95) ~[mybatis-3.5.7.jar:3.5.7]at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:86) ~[mybatis-3.5.7.jar:3.5.7]at com.sun.proxy.$Proxy54.findAll(Unknown Source) ~[na:na]at com.wuhan.it.service.impl.PermissionService.findAll(PermissionService.java:19) ~[classes/:na]at com.wuhan.it.controller.PermissionController.findAll(PermissionController.java:23) ~[classes/:na]at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_144]at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_144]at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_144]at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_144]at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) ~[spring-web-5.2.9.RELEASE.jar:5.2.9.RELEASE]at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) ~[spring-web-5.2.9.RELEASE.jar:5.2.9.RELEASE]at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) ~[spring-webmvc-5.2.9.RELEASE.jar:5.2.9.RELEASE]at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) ~[spring-webmvc-5.2.9.RELEASE.jar:5.2.9.RELEASE]at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) ~[spring-webmvc-5.2.9.RELEASE.jar:5.2.9.RELEASE]at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.2.9.RELEASE.jar:5.2.9.RELEASE]at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) ~[spring-webmvc-5.2.9.RELEASE.jar:5.2.9.RELEASE]at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) ~[spring-webmvc-5.2.9.RELEASE.jar:5.2.9.RELEASE]at org.springframework.web.servlet.frameworkServlet.processRequest(frameworkServlet.java:1006) ~[spring-webmvc-5.2.9.RELEASE.jar:5.2.9.RELEASE]at org.springframework.web.servlet.frameworkServlet.doGet(frameworkServlet.java:898) ~[spring-webmvc-5.2.9.RELEASE.jar:5.2.9.RELEASE]
目录结构错误,应该放在上面,正确目录如下
2,xml介绍
type后面要加实体带有路径,否则会报找不到路径
<?xml version="1.0" encoding="UTF-8" ?>
3,启动类
import org.mybatis.spring.annotation.MapperScan;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplication@MapperScan("com.wuhan.it")public class Application { public static void main(String[] args) { SpringApplication.run(Application.class,args); }}
4controller
package com.wuhan.it.controller;import com.wuhan.it.model.PermissionModel;import com.wuhan.it.service.impl.PermissionService;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.web.bind.annotation.GetMapping;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;@RestController@RequestMapping("/permission")public class PermissionController { @Autowired private PermissionService permissionService; @GetMapping("/findAll") public PermissionModel findAll(){ return permissionService.findAll(); }}
5,mapper
package com.wuhan.it.mapper;import com.wuhan.it.model.PermissionModel;import org.apache.ibatis.annotations.Mapper;@Mapperpublic interface PermissionMapper { PermissionModel findAll();}
6,model实体类
package com.wuhan.it.model;public class PermissionModel {}
7,service
package com.wuhan.it.service;import com.wuhan.it.model.PermissionModel;public interface IPermissionService { PermissionModel findAll();}
8,impl
package com.wuhan.it.service.impl;import com.wuhan.it.mapper.PermissionMapper;import com.wuhan.it.model.PermissionModel;import com.wuhan.it.service.IPermissionService;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service;@Servicepublic class PermissionService implements IPermissionService { @Autowired private PermissionMapper permissionMapper; public PermissionModel findAll() { return permissionMapper.findAll(); }}