我有一个泛型类DefaultBatchReportService。 我想通过不同的POJO课程,服务和Dao进入这个通用类。
但是,我发现将特定类传递给具有内部自动装配泛型类的泛型抽象类存在困难。
我收到如下错误:
2016年2月2日下午1:49:10 com.sun.faces.application.view.ViewScopeManager
2016年2月2日下午1:49:10 com.sun.faces.lifecycle.InvokeApplicationPhase 执行警告:创建名称为' rt001Bean':注入的bean时出错 自动连接的依赖关系失败;嵌套异常是 org.springframework.beans.factory.BeanCreationException:不能 autowire字段:私有 com.edgar.report.core.DefaultBatchReportService com.edgar.test.RT001Bean.bReportController;嵌套异常是 org.springframework.beans.factory.BeanCreationException:错误 创建名称为' defaultBatchReportService':注入的bean 自动连接依赖失败;嵌套异常是 org.springframework.beans.factory.BeanCreationException:不能 autowire字段:private com.edgar.report.core.SingleReportService com.edgar.report.core.DefaultBatchReportService.singleReportService; 嵌套异常是 org.springframework.beans.factory.NoUniqueBeanDefinitionException:没有 [com.edgar.report.core.SingleReportService]类型的限定bean是 已定义:预期的单个匹配bean但找到3:RT001Service, RT002Service,RT003Service org.springframework.beans.factory.BeanCreationException:错误 创建名为' rt001Bean'的bean:注入自动装配 依赖失败;嵌套异常是 org.springframework.beans.factory.BeanCreationException:不能 autowire字段:私有 com.edgar.report.core.DefaultBatchReportService com.edgar.test.RT001Bean.bReportController;嵌套异常是 org.springframework.beans.factory.BeanCreationException:错误 创建名称为' defaultBatchReportService':注入的bean 自动连接依赖失败;嵌套异常是 org.springframework.beans.factory.BeanCreationException:不能 autowire字段:private com.edgar.report.core.SingleReportService com.edgar.report.core.DefaultBatchReportService.singleReportService; 嵌套异常是 org.springframework.beans.factory.NoUniqueBeanDefinitionException:没有 [com.edgar.report.core.SingleReportService]类型的限定bean是 已定义:预期单个匹配bean但找到3: RT001Service,RT002Service,RT003Service at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1210) 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) 在 org.springframework.beans.factory.support.AbstractBeanFactory $ 2.getObject(AbstractBeanFactory.java:342) 在com.gitgub.javaplugs.jsf.ViewScope.get(ViewScope.java:69)at at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:337) 在 org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) 在 org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:956) 在 org.springframework.beans.factory.access.el.SpringBeanELResolver.getValue(SpringBeanELResolver.java:55) 在 com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176) 在 com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203) 在org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:71) 在org.apache.el.parser.AstValue.getTarget(AstValue.java:93)at org.apache.el.parser.AstValue.invoke(AstValue.java:259)at at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:273) 在 com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105) 在 javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87) 在 com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102) 在 org.primefaces.application.DialogActionListener.processAction(DialogActionListener.java:45) 在javax.faces.component.UICommand.broadcast(UICommand.java:315)at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790) 在 javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282) 在 com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81) 在com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198) 在javax.faces.webapp.FacesServlet.service(FacesServlet.java:658)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) 在 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) 在 org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:78) 在 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) 在 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) 在 org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 在 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) 在 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) 在 org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:316) 在 org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:115) 在 org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) 在 org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:330) 在 org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) 在 org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) 在 com.edgar.bean.MDCFilterSecurityInterceptor.doFilter(MDCFilterSecurityInterceptor.java:24) 在 org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:330) 在 org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:114) 在 org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:330) 在 org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:122) 在 org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:330) 在 org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) 在 org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:330) 在 org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:168) 在 org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:330) 在 org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:48) 在 org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:330) 在 org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:205) 在 org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:330) 在 org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:120) 在 org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:330) 在 org.springframework.security.web.csrf.CsrfFilter.doFilterInternal(CsrfFilter.java:120) 在 org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 在 org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:330) 在 org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:64) 在 org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 在 org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:330) 在 org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:53) 在 org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 在 org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:330) 在 org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:91) 在 org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:330) 在 org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:213) 在 org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:176) 在 org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344) 在 org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261) 在 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) 在 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) 在 org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:85) 在 org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 在 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) 在 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) 在 org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) 在 org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) 在 org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505) 在 org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170) 在 org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) 在 org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:957) 在 org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) 在 org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423) 在 org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079) 在 org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process(AbstractProtocol.java:620) 在 org.apache.tomcat.util.net.JIoEndpoint $ SocketProcessor.run(JIoEndpoint.java:318) 在 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 在 java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:615) 在 org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61) 在java.lang.Thread.run(Thread.java:745)
@Component
@Scope("prototype")
public class DefaultBatchReportService <T extends SingleReportService, I extends ReportInputParam, M extends ReportMeta, MD extends ReportMetaDetail, C extends ReportContent, P extends ReportDao<I , M, MD, C>> {
@Setter
private I inputParam;
@Setter
private M meta;
@Autowired
@Setter
private T singleReportService;
@Autowired
@Setter
private P reportDao;
}
@Component
@SpringScopeView
@Getter
@Setter
public class RT001Bean extends BaseBean {
@Autowired
private DefaultBatchReportService<RT001Service, RT001_InputParam, RT001_Meta, RT001_Meta.Detail, RT001_Content, RT001Dao> bReportController;
private RT001_InputParam inputParam;
public void generateBatchReport() {
//Start Report Generation
try {
bReportController.doSomething(inputParam);
....
} catch (CustomException e) {
// Print Error Message
}
}
在这个项目中,我的团队正在使用JSF-Spring集成框架。正常标准的控件注入工作正常(没有通用类型)。
我的项目中有多个具有相同过程的批处理报告,这就是为什么我想通过将不同的类传递给它来使用DefaultBatchReportService来处理每个BatchReport。 (RT001 ...,RT002 ...,RT003 ..)然后,开发人员可以专注于绘制单个&#39;报告。
抱歉我的英语不好:/