title: How to use MyBatis/Spring from main()
body: <p>So I've been working on a web application using MyBatis and Spring. I realized that I will need a nightly batch process. I'd like to be able to reuse my MyBatis code and use Spring so I can autowire things, but the autowiring doesn't seem to be working. Basically, I want to be able to do this: </p>
  
  <pre><code>public class mainMethod{
      @Autowired
      Mapper m; 
  
      public static void main(String args[])
      {
         System.out.println(m.selectByPrimaryKey("key"); 
      }
  }
  </code></pre>
  
  <p>Obviously, this is an overly simplified example, but once that works, I'll be able to do everything else I need to. Right now, m is null, and I'm not sure how to make it autowire properly. </p>