title: How to use JSR 330 with Spring as implementation without any XML and without spring specific annotations?
body: <p>I wanted to use JSR330 (@Inject @Named, @Singleton, ...).  So as spring is commonly used I wanted to use spring as the underlying implementation.  But I don't get if its possible to use:</p>
  
  <ol>
  <li><strong>With JSR330</strong></li>
  <li><strong>With Spring as implementation</strong></li>
  <li><strong>Without spring specific annotations</strong> only JSR330 annotations allowed.  Isn't that what the specification is all about.</li>
  <li><strong>Without XML</strong></li>
  </ol>
  
  <p>I tried the below with no success:</p>
  
  <pre><code>package org.di.spring;
  
  import org.springframework.context.ApplicationContext;
  import org.springframework.context.annotation.AnnotationConfigApplicationContext;
  import org.springframework.context.annotation.ComponentScan;
  import org.springframework.context.annotation.Configuration;
  import org.tomerbd.snippets.nlp.OpenNLP;
  
  import javax.inject.Inject;
  
  // A failed attempt to achieve: DI + JSR330 + Spring + NoSpring Specific Annotations + No XML
  // I didn't want to have any spring annotations but it looks like I have to, wanted to be pure JSR330.
  @Configuration
  @ComponentScan
  public class DIJSR330NoXML {
  
      public static class UseMe {
          public String getMe() { return "here I am"; }
      }
  
      public static class IWillUseYou {
          @Inject private UseMe useMe;
  
          public String letsUseHim() {
              return useMe.getMe();
          }
      }
  
      public static void main(String[] args) throws Exception {
          ApplicationContext ctx = new AnnotationConfigApplicationContext("org.di.spring");
          ((AnnotationConfigApplicationContext) ctx).refresh();
          IWillUseYou user = ctx.getBean(IWillUseYou.class); // any other way to get class? I don't want to use spring annotations only jsr330 please with spring as impl!
          System.out.println(user.letsUseHim());
  
      }
  }
  </code></pre>
  
  <p>got failed output:</p>
  
  <pre><code>20:25:38.509 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Eagerly caching bean 'DIJSR330NoXML' to allow for resolving potential circular references
  20:25:38.564 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Finished creating instance of bean 'DIJSR330NoXML'
  20:25:38.566 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.context.event.internalEventListenerFactory'
  20:25:38.794 [main] DEBUG org.springframework.context.annotation.AnnotationConfigApplicationContext - Unable to locate LifecycleProcessor with name 'lifecycleProcessor': using default [org.springframework.context.support.DefaultLifecycleProcessor@51c693d]
  20:25:38.805 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'lifecycleProcessor'
  20:25:38.813 [main] DEBUG org.springframework.core.env.PropertySourcesPropertyResolver - Could not find key 'spring.liveBeansView.mbeanDomain' in any property source
  Exception in thread "main" org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.di.spring.DIJSR330NoXML$IWillUseYou' available
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:347)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:334)
      at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1107)
      at org.di.spring.DIJSR330NoXML.main(DIJSR330NoXML.java:31)
  
  Process finished with exit code 1
  </code></pre>
  
  <p>So if JSR330 presented DI and spring supports JSR330 is it possible to use Spring with <strong>Only</strong> JSR 330 annotations and without any spring XML?</p>
  
  <p>If this is not possible just impossible could you tell me what is the absolute minimal set of spring annotations (with no xml please) that I need to use in order to have it working.</p>