我改變了代碼。原因是bean無法建立。春天,aop,批次重試,例外:預計單一豆但發現0
如果我不添加重試,它的工作原理。如果我不添加重試,它會起作用。
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="www.springframework.org/schema/beans"
xmlns:xsi="www.w3.org/2001/XMLSchema-instance"
xmlns:util="www.springframework.org/schema/util"
xmlns:aop="www.springframework.org/schema/aop"
xmlns:context="www.springframework.org/schema/context"
xsi:schemaLocation="
www.springframework.org/schema/beans www.springframework.org/schema/beans/spring-beans-3.0.xsd
www.springframework.org/schema/util www.springframework.org/schema/util/spring-util-3.0.xsd
www.springframework.org/schema/aop www.springframework.org/schema/aop/spring-aop-3.0.xsd
www.springframework.org/schema/context www.springframework.org/schema/context/spring-context-3.0.xsd
">
<bean class="com.company.team.task.taskMonitorImpl"/>
<aop:config>
<aop:pointcut id="taskCheck" expression="execution(* com.company.team.task.taskMonitorImpl.*(..))" />
<aop:advisor pointcut-ref="taskCheck" advice-ref="taskRetryAdvice" />
</aop:config>
<bean id="taskRetryAdvice" class="org.springframework.batch.retry.interceptor.RetryOperationsInterceptor">
<property name="RetryOperations" ref="taskBatchRetryTemplate" />
</bean>
<bean id="taskBatchRetryTemplate" class="org.springframework.batch.retry.support.RetryTemplate">
<property name="retryPolicy" ref="taskBatchRetryPolicy" />
<property name="backOffPolicy" ref="ExponentialBackOffPolicy" />
</bean>
<bean id="taskBatchRetryPolicy" class="org.springframework.batch.retry.policy.SimpleRetryPolicy">
<constructor-arg index="0" value="3"/>
<constructor-arg index="1">
<map>
<entry key="java.lang.RuntimeException" value="true"/>
</map>
</constructor-arg>
</bean>
<bean id="ExponentialBackOffPolicy" class="org.springframework.batch.retry.backoff.ExponentialBackOffPolicy">
<property name="initialInterval" value="300" >
<description>Initial sleep interval value, default 300 ms</description>
</property>
<property name="maxInterval" value="30000" >
<description>The maximum value of the backoff period in milliseconds.</description>
</property>
<property name="multiplier" value="2.0" >
<description>The value to increment the exp seed with for each retry attempt.</description>
</property>
</bean>
<!--<context:annotation-config />-->
</beans>
log4j:WARN No appenders could be found for logger (org.springframework.context.support.ClassPathXmlApplicationContext).
log4j:WARN Please initialize the log4j system properly.
INFO: Detected JCL Provider: Commons Logging [commons-logging-api-1.1.1.jar]
INFO: Detected JCL Implementation: Commons Logging [commons-logging-adapters-1.1.1.jar]
INFO: JCL output is LOG4J
INFO: log4j.appender.APPLICATION.File = /home/me/workspace/src/teamListingDestinationWorkflow/build/private/var/output/logs/teamListingDestinationWorkflow.log
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.company.team.teamListingDstWorkflow.teamListingDstWorkflowMain#0': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.company.team.task.taskMonitorImpl com.company.team.teamListingDstWorkflow.teamListingDstWorkflowMain.mon; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.company.team.task.taskMonitorImpl] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:288)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.company.team.teamListingDstWorkflow.teamListingDstWorkflowMain.<clinit>(teamListingDstWorkflowMain.java:29)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.company.team.task.taskMonitorImpl com.company.team.teamListingDstWorkflow.teamListingDstWorkflowMain.mon; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.company.team.task.taskMonitorImpl] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:508)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)
... 13 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.company.team.task.taskMonitorImpl] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:924)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:793)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480)
... 15 more
我的問題:讓 「重試」 的作品提前
感謝。
我只能爲自己說話,但我真的不明白你的要求。如果你寫更多的文字,這可能會有所幫助。並添加全堆棧跟蹤 – Ralph
解決!!! 加 鏈路以下:http://stackoverflow.com/questions/ 841231/fixing-beannotofrequiredtypeexception-on-spring-proxy-cast-on-a-non-singleton-be –
Peter