title: using java main method load SpringContext, Annatation Can't get the bean
body: <p>Using <code>Java</code> main method load <code>SpringContext</code>. <code>Annatation</code> can't get the bean.</p>
  
  <p>Java method code:</p>
  
  <pre><code>ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"spring-mybatis.xml"});
  
      context.start();
      UserMapper userMapper = (UserMapper)context.getBean("userMapper");
      System.out.println("userMapper-----&gt;:" + userMapper);   //this line can get the bean,and print the bean's Memory Address
      while(true){
          Thread.sleep(1000);
      }
  </code></pre>
  
  <p>But when I using the <code>Annatation</code> get the bean, can not get it,return the NULL
  java code:</p>
  
  <pre><code>@Resource
  
  private UserMapper userMapper;
  </code></pre>