title: spring 3.1 annotated autowiring on standalone application
body: <p>i wrote this app with eclipse and it works. But when i deploy it as standalone/console application, it cannot find StartApp bean i've injected.
  here's the codes:</p>
  
  <p>main app:</p>
  
  <pre><code>@Component
  public class StartApp {
      @Autowired
      private Processor proc;
  
      public StartApp() {
          System.out.println("Starting App!");
      }
      private void say() {
          proc.say();
      }
      public static void main(String[] args) {
          ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
          StartApp app = ctx.getBean(StartApp.class);
          app.say();
      }
  }
  </code></pre>
  
  <p>service:</p>
  
  <pre><code>@Service
  public class Processor {
      public Processor() {
          System.out.println("Processor initialized!");
      }
      public void say() {
          System.out.println("hello!");
      }
  }
  </code></pre>
  
  <p>and applicationContext.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xmlns:context="http://www.springframework.org/schema/context" 
      xmlns:p="http://www.springframework.org/schema/p"
      xsi:schemaLocation="http://www.springframework.org/schema/beans 
      http://www.springframework.org/schema/beans/spring-beans-3.1.xsd 
      http://www.springframework.org/schema/context 
      http://www.springframework.org/schema/context/spring-context-3.1.xsd"&gt;
  
      &lt;context:component-scan base-package="test.spring.desktop"/&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>i did put all spring libraries and logger including slf4j libraries.
  and for console command i put these:</p>
  
  <pre><code>java -cp lib/*:lib/spring-3.1/*:test-spring-desktop.jar test.spring.desktop.StartApp
  </code></pre>
  
  <p>then i got these error message:</p>
  
  <pre><code>Exception in thread "main" org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [test.spring.desktop.StartApp] is defined: expected single bean but found 0:
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:271)
          at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1101)
          at test.spring.desktop.StartApp.main(StartApp.java:24)
  </code></pre>