我编写了一个用于简单查询的spring批处理应用程序。这对于第一次使用某些作业Id很好,但是对于下一次执行,它需要新的作业Id。为此编写了jobParamIncrementer类,仍然得到bean defn未找到异常。我不太明白发生了什么。请帮帮我。
下面是堆栈跟踪。
Job Paramater {run.id=1370337260531}
Jun 4, 2013 2:44:20 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@10b9d04: startup date [Tue Jun 04 14:44:20 IST 2013]; root of context hierarchy
Jun 4, 2013 2:44:20 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [applicationContext.xml]
Jun 4, 2013 2:44:20 PM org.springframework.beans.factory.support.DefaultListableBeanFactory registerBeanDefinition
INFO: Overriding bean definition for bean 'uniqueJob': replacing [Generic bean: class [org.springframework.batch.core.configuration.xml.SimpleFlowFactoryBean]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] with [Generic bean: class [org.springframework.batch.core.configuration.xml.JobParserJobFactoryBean]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null]
Jun 4, 2013 2:44:21 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@ccc588: defining beans [dataSource,transactionManager,jdbcTemplate,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,jobRepository,jobLauncher,org.springframework.batch.core.scope.internalStepScope,org.springframework.beans.factory.config.CustomEditorConfigurer,org.springframework.batch.core.configuration.xml.CoreNamespacePostProcessor,step1,uniqueJob,e4XCountriesRowMapper,jobParamIncrementer,cursorReader,flatFileWriter]; root of factory hierarchy
Jun 4, 2013 2:44:21 PM org.springframework.jdbc.datasource.DriverManagerDataSource setDriverClassName
INFO: Loaded JDBC driver: com.mysql.jdbc.Driver
Jun 4, 2013 2:44:21 PM org.springframework.batch.core.launch.support.SimpleJobLauncher afterPropertiesSet
INFO: No TaskExecutor has been set, defaulting to synchronous executor.
Jun 4, 2013 2:44:21 PM org.springframework.batch.core.launch.support.CommandLineJobRunner start
SEVERE: Job Terminated in error: No bean named '{run.id=1370337260531}' is defined
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named '{run.id=1370337260531}' is defined
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:568)
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1108)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:278)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1045)
at org.springframework.batch.core.launch.support.CommandLineJobRunner.start(CommandLineJobRunner.java:339)
at org.springframework.batch.core.launch.support.CommandLineJobRunner.main(CommandLineJobRunner.java:574)
at com.JobRunner.main(JobRunner.java:179)
Jun 4, 2013 2:44:21 PM org.springframework.context.support.AbstractApplicationContext doClose
INFO: Closing org.springframework.context.support.ClassPathXmlApplicationContext@10b9d04: startup date [Tue Jun 04 14:44:20 IST 2013]; root of context hierarchy
Jun 4, 2013 2:44:21 PM org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons
INFO: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@ccc588: defining beans [dataSource,transactionManager,jdbcTemplate,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,jobRepository,jobLauncher,org.springframework.batch.core.scope.internalStepScope,org.springframework.beans.factory.config.CustomEditorConfigurer,org.springframework.batch.core.configuration.xml.CoreNamespacePostProcessor,step1,uniqueJob,e4XCountriesRowMapper,jobParamIncrementer,cursorReader,flatFileWriter]; root of factory hierarchy
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:batch="http://www.springframework.org/schema/batch" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.1.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://<ip>/test" />
<property name="username" value="root" />
<property name="password" value="" />
</bean>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="dataSource" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
<bean id="jobRepository" class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean">
<property name="databaseType" value="MYSQL"/>
<property name="dataSource" ref="dataSource"/>
<property name="transactionManager" ref="transactionManager"/> </bean>
<bean id="jobLauncher"
class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
<property name="jobRepository" ref="jobRepository" />
</bean>
<!-- BD to CSV -->
<!-- <batch:job id="sampleJob" incrementer="jobParamIncrementer"> -->
<batch:job id="uniqueJob" incrementer="jobParamIncrementer">
<batch:step id="step1">
<batch:tasklet>
<batch:chunk reader="cursorReader" writer="flatFileWriter"
commit-interval="1000" />
</batch:tasklet>
</batch:step>
</batch:job>
<bean id="e4XCountriesRowMapper" class="com.E4XCountriesRowMapper">
</bean>
<bean name="jobParamIncrementer" class="com.JobParamIncrementer">
</bean>
<bean id="cursorReader"
class="org.springframework.batch.item.database.JdbcCursorItemReader">
<property name="dataSource" ref="dataSource" />
<property name="sql" value="select * from e4x_countries" />
<property name="rowMapper" ref="e4XCountriesRowMapper" />
</bean>
<bean id="flatFileWriter" class="org.springframework.batch.item.file.FlatFileItemWriter">
<property name="resource"
value="file:fileNme.txt" />
<property name="lineAggregator">
<bean
class="org.springframework.batch.item.file.transform.DelimitedLineAggregator">
<property name="delimiter" value="," /> <!-- default -->
<property name="fieldExtractor">
<bean
class="org.springframework.batch.item.file.transform.BeanWrapperFieldExtractor">
<property name="names"
value="countryCode,countryName,currencyCode,currencyName,currencySymbol" />
</bean>
</property>
</bean>
</property>
</bean>
</beans>
public class JobParamIncrementer implements JobParametersIncrementer {
public JobParameters getNext(JobParameters parameters) {
System.out.println("got job parameters: " + parameters);
/*if (parameters==null || parameters.isEmpty()) {
return new JobParametersBuilder().addLong("run.id", 1L).toJobParameters();
}*/
return new JobParametersBuilder().addLong("run.id", Calendar.getInstance().getTimeInMillis()).toJobParameters();
/*long id = parameters.getLong("run.id",Calendar.getInstance().getTimeInMillis()) + 1;
JobParametersBuilder jobParamBuilder = new JobParametersBuilder().addLong("run.id", id);
return jobParamBuilder.toJobParameters();*/
}
}
乔布伦纳(主班)
public class JobRunner {
public static void main(String[] args) {
JobParamIncrementer jobName = new JobParamIncrementer();
try {
String id=jobName.getNext(null)+"";
System.out.println("Job Paramater "+id+"");
CommandLineJobRunner.main(new String[] { "applicationContext.xml", id});
System.out.println("DONE");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
看起来您没有将作业名传递给CommandLineJobrunner。尝试将Jobrunner.Main()方法中对CommandLineJobrunner.Main的调用更改为:
CommandLineJobRunner.main(new String[] { "applicationContext.xml", "uniqueJob", id});
我有以下工作要处理在一定的时间间隔或特别的基础上。 作业中的步骤如下: 我也想要用户界面,在那里我可以触发一个特别的基础上的工作,而且我应该能够提供参数从用户界面。 我想用Spring batch来完成这个任务,但它更多的是用于读->处理->写之类的工作。这里,在第一步中,我正在生成由第二步读取的数据。我不确定我是否还可以使用Spring batch来实现这个,或者有更好的方法来实现这个。
我想创建带有Spring批处理Rest控制器和动态输入文件名的项目。 我的代码:Rest控制器 公共类FileNameController{ } 作业配置: @EnableBatchProcessing公共类JobConfig{ } 我写网址的时候:http://localhost:8080/launch job?fileName=djecc5cpt.csv控制台打印: SQL语法[SELECTJ
我知道匹配模式解析器,这是Spring批处理提供的。我需要关于如何构造批处理作业的帮助,以便它可以读取循环中的记录类型5和记录类型6。
我们正试图建立关于如何在大型IT服务中使用Spring Batch的标准,并具有不同的商业利益。 我们可能会有几个属于不同业务领域的批次。我们已经知道其中一些必须从所有批次通用的表中获取一些参数(即Java和COBOL;例如日期参数)。 我们将实现的Spring批处理作业的数量很难评估。没有重写现有COBOL批次的目标,只要有可能,就鼓励连续流程处理。 一些关于概念证明的问题不时出现,但目前几乎没
我想用插页。。请务必更新。。对两列具有唯一约束的表的语法。这可能吗? mytable对col1和col2有单独的唯一约束。 我可以写: 然而,这不起作用: 错误:冲突时,更新是否需要推理规范或约束名称 这也不起作用: 错误:不存在与冲突规范匹配的唯一或排除约束 这种语法似乎是为两列上的单一复合唯一约束而设计的,而不是两个约束。 如果违反了其中一个唯一约束,有没有办法进行条件更新?这个问题是如何在博