title: MyBatis Spring MVC Error: Invalid bound statement (not found)
body: <p>Here is the stack trace when I try to execute a simple query using MyBatis: </p>
  
  <pre><code>org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.my.package.persistence.BrandMapper.getBrand
      org.apache.ibatis.binding.MapperMethod$SqlCommand.&lt;init&gt;(MapperMethod.java:189)
      org.apache.ibatis.binding.MapperMethod.&lt;init&gt;(MapperMethod.java:43)
      org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:58)
      org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:51)
      com.sun.proxy.$Proxy25.getBrand(Unknown Source)
      com.my.package.service.BrandService.getBrand(BrandService.java:18)
      com.my.package.service.BrandService$$FastClassBySpringCGLIB$$1140c60a.invoke(&lt;generated&gt;)
      org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
      org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:649)
      com.my.package.service.BrandService$$EnhancerBySpringCGLIB$$ea6f89cd.getBrand(&lt;generated&gt;)
      com.my.package.controller.HomeController.getBrands(HomeController.java:28)
      sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      java.lang.reflect.Method.invoke(Method.java:483)
      org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
      org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
      org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
      org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:777)
      org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:706)
      org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
      org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943)
      org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
      org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
      org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
      org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
      org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  </code></pre>
  
  <p>I'm using Javaconfig syntax instead of XML configuration. Here is my PersistenceConfig:</p>
  
  <pre><code>@Configuration
  @EnableTransactionManagement
  @MapperScan("com.my.package.persistence")
  public class PersistenceConfig {
  
      @Bean
      public DataSource dataSource() {
  
          DriverManagerDataSource dataSource = new DriverManagerDataSource();
  
          try {
              dataSource.setDriverClassName("com.mysql.jdbc.Driver");
              dataSource.setUrl("jdbc:mysql//localhost:3306/db");
              dataSource.setUsername("dbuser");
              dataSource.setPassword("dbpassword");
          } catch (Exception e) {
              System.out.print(e);
          }
          return dataSource;
      }
  
      @Bean
      public DataSourceTransactionManager transactionManager() {
          return new DataSourceTransactionManager(dataSource());
      }
  
      @Bean
      public SqlSessionFactoryBean sqlSessionFactory() throws Exception {
          SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
          sessionFactory.setDataSource(dataSource());
          sessionFactory.setTypeAliasesPackage("com.my.package.domain");
          return sessionFactory;
      }
  }
  </code></pre>
  
  <p>Here is my controller:</p>
  
  <pre><code>@Controller
  public class HomeController {
  
      private static Logger logger = LoggerFactory.getLogger(HomeController.class);
  
      @Autowired
      private BrandService brandService;
  
      @RequestMapping(value = "/", method = RequestMethod.GET)
      public String index() {
          return "index";
      }
  
      @RequestMapping(value = "/brands", method = RequestMethod.GET)
      public String getBrands(Model model) {
          model.addAttribute("brands",brandService.getBrand(1));
          return "brands";
      }
  
  }
  </code></pre>
  
  <p>Here is my Brand Mapper Interface:</p>
  
  <pre><code>public interface BrandMapper {
  
      Brand getBrand(int id);
  
      Brand getBrandByName(String name);
  
      List&lt;Brand&gt; getBrandList();
  
      void addBrand(Brand brand);
  
      void updateBrand(Brand brand);
  
      void deleteBrand(int id);
  
  }
  </code></pre>
  
  <p>Here is my BrandMapper XML:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
          "http://mybatis.org/dtd/mybatis-3-mapper.dtd"&gt;
  
  &lt;mapper namespace="com.my.package.persistence.BrandMapper"&gt;
  
      &lt;select id="getBrand" resultType="Brand" parameterType="int"&gt;
          SELECT id, name
          FROM brand
          WHERE id = #{id};
      &lt;/select&gt;
  
      &lt;select id="getBrandByName" resultType="Brand" parameterType="String"&gt;
          SELECT id, name
          FROM brand
          WHERE name = #{name};
      &lt;/select&gt;
  
      &lt;select id="getBrandList" resultType="Brand"&gt;
          SELECT id, name
          FROM brand;
      &lt;/select&gt;
  
      &lt;insert id="addBrand" parameterType="Brand"&gt;
          INSERT INTO brand (id, name)
          VALUE (#{id}, #{name})
      &lt;/insert&gt;
  
      &lt;update id="updateBrand" parameterType="Brand"&gt;
          UPDATE brand
          SET
          name = #{name}
          where id = #{id}
      &lt;/update&gt;
  
      &lt;delete id="deleteBrand" parameterType="int"&gt;
          DELETE FROM brand
          WHERE id = #{id}
      &lt;/delete&gt;
  
  &lt;/mapper&gt;
  </code></pre>
  
  <p>I've done some research, but none of the solutions have worked for me. My XML Mapper files are under resources in a package named "com.my.package.persistence"</p>
  
  <p>Does anyone have an idea what's wrong here? </p>
  
  <p>Thanks in advance</p>