Java Spring批处理:SimpleJobRepository-示例不工作
我一直在尝试让Spring Batch Hello World 3示例从运行 我丢失了一些罐子,有人帮了我,使项目运行得更好,但我仍然有一个错误。。有人能帮我吗 这是我的applicationContext.xmlJava Spring批处理:SimpleJobRepository-示例不工作,java,spring,spring-batch,Java,Spring,Spring Batch,我一直在尝试让Spring Batch Hello World 3示例从运行 我丢失了一些罐子,有人帮了我,使项目运行得更好,但我仍然有一个错误。。有人能帮我吗 这是我的applicationContext.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.o
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="jobLauncher" class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
<property name="jobRepository" ref="jobRepository"/>
</bean>
<bean id="jobRepository" class="org.springframework.batch.core.repository.support.SimpleJobRepository">
<constructor-arg>
<bean class="org.springframework.batch.core.repository.dao.MapJobInstanceDao"/>
</constructor-arg>
<constructor-arg>
<bean class="org.springframework.batch.core.repository.dao.MapJobExecutionDao" />
</constructor-arg>
<constructor-arg>
<bean class="org.springframework.batch.core.repository.dao.MapStepExecutionDao"/>
</constructor-arg>
<constructor-arg>
<bean class="org.springframework.batch.core.repository.dao.MapExecutionContextDao"/>
</constructor-arg>
</bean>
</beans>
这就是我在控制台上遇到的错误
INFO: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@48ff2413: defining beans [jobLauncher,jobRepository,transactionManager,step,itemReader,lineTokenizer,fieldSetMapper,itemWriter,lineAggregator,simpleJob]; root of factory hierarchy
Oct 27, 2011 1:59:46 PM org.springframework.batch.core.launch.support.CommandLineJobRunner start
SEVERE: Job Terminated in error:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'step' defined in class path resource [itemOrientedJob.xml]: Cannot resolve reference to bean 'itemReader' while setting bean property 'itemReader'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'itemReader' defined in class path resource [itemOrientedJob.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'lineTokenizer' of bean class [org.springframework.batch.item.file.FlatFileItemReader]: Bean property 'lineTokenizer' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
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:567)
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 org.springframework.batch.core.launch.support.CommandLineJobRunner.start(CommandLineJobRunner.java:190)
at org.springframework.batch.core.launch.support.CommandLineJobRunner.main(CommandLineJobRunner.java:254)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'itemReader' defined in class path resource [itemOrientedJob.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'lineTokenizer' of bean class [org.springframework.batch.item.file.FlatFileItemReader]: Bean property 'lineTokenizer' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1361)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
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.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
... 16 more
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'lineTokenizer' of bean class [org.springframework.batch.item.file.FlatFileItemReader]: Bean property 'lineTokenizer' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1052)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:921)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:76)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1358)
... 24 more
INFO:在org.springframework.beans.factory.support中销毁单例。DefaultListableBeanFactory@48ff2413:定义bean[jobLauncher、jobRepository、transactionManager、step、itemReader、lineTokenizer、fieldSetMapper、itemWriter、lineAggregator、simpleJob];工厂层次结构的根
2011年10月27日下午1:59:46 org.springframework.batch.core.launch.support.CommandLineJobRunner开始
严重:作业错误终止:
org.springframework.beans.factory.BeanCreationException:创建名为“step”的bean时出错,该bean在类路径资源[itemOrientedJob.xml]中定义:设置bean属性“itemReader”时无法解析对bean“itemReader”的引用;嵌套异常为org.springframework.beans.factory.BeanCreationException:创建名为“itemReader”的bean时出错,该bean在类路径资源[itemOrientedJob.xml]中定义:设置属性值时出错;嵌套异常为org.springframework.beans.NotWritablePropertyException:bean类[org.springframework.batch.item.file.FlatFileItemReader]的无效属性“lineTokenizer”:bean属性“lineTokenizer”不可写或具有无效的setter方法。setter的参数类型与getter的返回类型匹配吗?
位于org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
在org.springframework.beans.factory.support.BeanDefinitionValueResolver.ResolveValueIfNeeded上(BeanDefinitionValueResolver.java:106)
位于org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325)
位于org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
位于org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
位于org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
位于org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
位于org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
位于org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
位于org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
位于org.springframework.beans.factory.support.DefaultListableBeanFactory.PreInstanceSingleton(DefaultListableBeanFactory.java:567)
位于org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
位于org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
位于org.springframework.context.support.ClassPathXmlApplicationContext。(ClassPathXmlApplicationContext.java:139)
位于org.springframework.context.support.ClassPathXmlApplicationContext。(ClassPathXmlApplicationContext.java:83)
位于org.springframework.batch.core.launch.support.CommandLineJobRunner.start(CommandLineJobRunner.java:190)
位于org.springframework.batch.core.launch.support.CommandLineJobRunner.main(CommandLineJobRunner.java:254)
原因:org.springframework.beans.factory.BeanCreationException:创建名为“itemReader”的bean时出错,该bean在类路径资源[itemOrientedJob.xml]中定义:设置属性值时出错;嵌套异常为org.springframework.beans.NotWritablePropertyException:bean类[org.springframework.batch.item.file.FlatFileItemReader]的无效属性“lineTokenizer”:bean属性“lineTokenizer”不可写或具有无效的setter方法。setter的参数类型与getter的返回类型匹配吗?
位于org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1361)
位于org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
位于org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
位于org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
位于org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
位于org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
位于org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
位于org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
位于org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
... 还有16个
原因:org.springframework.beans.NotWritablePropertyException:bean类[org.springframework.batch.item.file.FlatFileItemReader]的无效属性“lineTokenizer”:bean属性“lineTokenizer”不可写或具有无效的setter方法。setter的参数类型与getter的返回类型匹配吗?
位于org.springframework.beans.BeanWrapperImpl.setPropertyVa
<bean id="jobRepository" class="org.springframework.batch.core.repository.support.SimpleJobRepository">
<constructor-arg>
<bean class="org.springframework.batch.core.repository.dao.MapJobInstanceDao"/>
</constructor-arg>
<constructor-arg>
<bean class="org.springframework.batch.core.repository.dao.MapJobExecutionDao" />
</constructor-arg>
<constructor-arg>
<bean class="org.springframework.batch.core.repository.dao.MapStepExecutionDao"/>
</constructor-arg>
<constructor-arg> <!-- Extra constructor argument -->
<bean class="org.springframework.batch.core.repository.dao.MapExecutionContextDao"/>
</constructor-arg>
</bean>