title: How to @Autowire generic type to inner generic class' bean without xml configuration?
body: <p>I have a generic class DefaultBatchReportService.
  I want to pass different POJO class, Service &amp; Dao into this generic class.</p>
  
  <p>However, I find difficulties in passing specific classes to generic abstract class with inner autowired generic class.</p>
  
  <p>I got errors as following:</p>
  
  <blockquote>
    <p>Feb 02, 2016 1:49:10 PM
    com.sun.faces.application.view.ViewScopeManager 
    
    <p>Feb 02, 2016 1:49:10 PM com.sun.faces.lifecycle.InvokeApplicationPhase
    execute WARNING: Error creating bean with name 'rt001Bean': Injection
    of autowired dependencies failed; nested exception is
    org.springframework.beans.factory.BeanCreationException: Could not
    autowire field: private
    com.edgar.report.core.DefaultBatchReportService
    com.edgar.test.RT001Bean.bReportController; nested exception is
    org.springframework.beans.factory.BeanCreationException: Error
    creating bean with name 'defaultBatchReportService': Injection of
    autowired dependencies failed; nested exception is
    org.springframework.beans.factory.BeanCreationException: Could not
    autowire field: private com.edgar.report.core.SingleReportService
    com.edgar.report.core.DefaultBatchReportService.singleReportService;
    nested exception is
    org.springframework.beans.factory.NoUniqueBeanDefinitionException: No
    qualifying bean of type [com.edgar.report.core.SingleReportService] is
    defined: expected single matching bean but found 3: RT001Service,
    RT002Service, RT003Service
    org.springframework.beans.factory.BeanCreationException: Error
    creating bean with name 'rt001Bean': Injection of autowired
    dependencies failed; nested exception is
    org.springframework.beans.factory.BeanCreationException: Could not
    autowire field: private
    com.edgar.report.core.DefaultBatchReportService
    com.edgar.test.RT001Bean.bReportController; nested exception is
    org.springframework.beans.factory.BeanCreationException: Error
    creating bean with name 'defaultBatchReportService': Injection of
    autowired dependencies failed; nested exception is
    org.springframework.beans.factory.BeanCreationException: Could not
    autowire field: private com.edgar.report.core.SingleReportService
    com.edgar.report.core.DefaultBatchReportService.singleReportService;
    nested exception is
    org.springframework.beans.factory.NoUniqueBeanDefinitionException: No
    qualifying bean of type [com.edgar.report.core.SingleReportService] is
    defined: expected single matching bean but found 3:
    RT001Service,RT002Service,RT003Service    at
    org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
      at
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1210)
      at
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
      at
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
      at
    org.springframework.beans.factory.support.AbstractBeanFactory$2.getObject(AbstractBeanFactory.java:342)
      at com.gitgub.javaplugs.jsf.ViewScope.get(ViewScope.java:69)    at
    org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:337)
      at
    org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
      at
    org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:956)
      at
    org.springframework.beans.factory.access.el.SpringBeanELResolver.getValue(SpringBeanELResolver.java:55)
      at
    com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
      at
    com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
      at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:71)
      at org.apache.el.parser.AstValue.getTarget(AstValue.java:93)    at
    org.apache.el.parser.AstValue.invoke(AstValue.java:259)   at
    org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:273)
      at
    com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
      at
    javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
      at
    com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
      at
    org.primefaces.application.DialogActionListener.processAction(DialogActionListener.java:45)
      at javax.faces.component.UICommand.broadcast(UICommand.java:315)    at
    javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
      at
    javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
      at
    com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)    at
    com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:658)   at
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
      at
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at
    org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:78)
      at
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      at
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      at
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      at
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:316)
      at
    org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:115)
      at
    org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90)
      at
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
      at
    org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126)
      at
    org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90)
      at
    com.edgar.bean.MDCFilterSecurityInterceptor.doFilter(MDCFilterSecurityInterceptor.java:24)
      at
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
      at
    org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:114)
      at
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
      at
    org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:122)
      at
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
      at
    org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
      at
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
      at
    org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:168)
      at
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
      at
    org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:48)
      at
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
      at
    org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:205)
      at
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
      at
    org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:120)
      at
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
      at
    org.springframework.security.web.csrf.CsrfFilter.doFilterInternal(CsrfFilter.java:120)
      at
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      at
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
      at
    org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:64)
      at
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      at
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
      at
    org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:53)
      at
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      at
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
      at
    org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:91)
      at
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
      at
    org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:213)
      at
    org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:176)
      at
    org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
      at
    org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
      at
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      at
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at
    org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:85)
      at
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      at
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      at
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
      at
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
      at
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
      at
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
      at
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
      at
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:957)
      at
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
      at
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
      at
    org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
      at
    org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620)
      at
    org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
      at
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      at
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      at
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      at java.lang.Thread.run(Thread.java:745)</p>
  </blockquote>
  
  <h1>Batch Report Service:</h1>
  
  <pre><code>@Component
  @Scope("prototype")
  public class DefaultBatchReportService &lt;T extends SingleReportService, I extends ReportInputParam, M extends ReportMeta, MD extends ReportMetaDetail, C extends ReportContent, P extends ReportDao&lt;I , M, MD, C&gt;&gt; {
      @Setter
      private I inputParam;
      @Setter
      private M meta;
  
      @Autowired
      @Setter
      private T singleReportService;
      @Autowired
      @Setter
      private P reportDao; 
  }
  </code></pre>
  
  <h1>Managed Bean Class:</h1>
  
  <pre><code>@Component
  @SpringScopeView
  @Getter
  @Setter
  public class RT001Bean extends BaseBean {
      @Autowired
      private DefaultBatchReportService&lt;RT001Service, RT001_InputParam, RT001_Meta, RT001_Meta.Detail, RT001_Content, RT001Dao&gt; bReportController;
  
      private RT001_InputParam inputParam;
  
      public void generateBatchReport() {
  
          //Start Report Generation
          try {
              bReportController.doSomething(inputParam);
              ....
          } catch (CustomException e) {
              // Print Error Message
  
      }
  }
  </code></pre>
  
  <p>In this project, my team is using JSF-Spring integrated framework. Normal standard injection of controls works fine (without Generic Types).</p>
  
  <p>There are more than one Batch Report with same procedures in my project, thats why I want to use DefaultBatchReportService to handle every BatchReport by passing different class to it. (RT001..., RT002..., RT003..) Then, developers can focus on drawing the 'single' report.</p>
  
  <p>Sorry for my poor English :/</p>