title: Spring IoC and Generic Interface Type
body: <p>I'm trying to use Spring IoC with an interface like this:</p>
  
  <pre><code>public interface ISimpleService&lt;T&gt; {
      void someOp(T t);
      T otherOp();
  }
  </code></pre>
  
  <p>Can Spring provide IoC based on the generic type argument T? I mean, something like this:</p>
  
  <pre><code>public class SpringIocTest {
      @Autowired
      ISimpleService&lt;Long&gt; longSvc;
  
      @Autowired
      ISimpleService&lt;String&gt; strSvc;
      //...
  }
  </code></pre>
  
  <p>Of course, my example above does not work:</p>
  
  <pre><code>expected single matching bean but found 2: [serviceLong, serviceString]
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:243)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:957)
  </code></pre>
  
  <p>My Question: is it possible to provide a similar functionality with minimum modifications to either the Interface or the implementing classes? I know for instance I can use @Qualifiers, but I want to keep things as simple as possible.</p>