运行作业时,springBatch 中的 ItemReadListener 未运行

我正在学习 spring Batch 抛出一个简单的例子,我从数据库中读取数据并将其写入 xml 文件。作业运行正常,但我看不到我放在 ItemReadListener 中的消息。我在配置中遗漏了什么吗?谢谢你的帮助。我会放最相关的代码,如果需要我可以添加更多。


工作.xml :


<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"

    xmlns:batch="http://www.springframework.org/schema/batch" 

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    xmlns:context="http://www.springframework.org/schema/context" 

    xmlns:jdbc="http://www.springframework.org/schema/jdbc">





            <bean id="itemReader" class="org.springframework.batch.item.database.JdbcPagingItemReader" scope="step">

      <property name="dataSource" ref="dataSource"/>

      <property name="queryProvider">

        <bean class="org.springframework.batch.item.database.support.SqlPagingQueryProviderFactoryBean">

          <property name="dataSource" ref="dataSource"></property>

          <property name="selectClause" value="SELECT internal_Id,individual_Id "></property>

          <property name="fromClause" value="FROM Person"></property>

          <property name="whereClause" value="where internal_Id &lt; :idMax"></property>

          <property name="sortKey" value="internal_Id"></property>

        </bean>

      </property>


      <property name="parameterValues">

        <map>

          <entry key="idMax" value="#{jobParameters['idMax']}"></entry>

        </map>

      </property>

      <property name="pageSize" value="10"></property>

      <property name="rowMapper">

        <bean class="sb.dbToxml.PersonRowMapper"></bean>

      </property>


    </bean>


叮当猫咪
浏览 277回答 1
1回答

MM们

监听器配置不正确。由此,&nbsp;<batch:job id="personJob">&nbsp; &nbsp; <batch:step id="step1bb1" >&nbsp; &nbsp; &nbsp; &nbsp; <batch:tasklet transaction-manager="transactionManager">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <batch:chunk reader="itemReader" writer="itemWriter"&nbsp; &nbsp;commit-interval="10" />&nbsp; &nbsp; &nbsp; &nbsp; </batch:tasklet>&nbsp; &nbsp; </batch:step>&nbsp; &nbsp; <batch:listeners>&nbsp; &nbsp; &nbsp; &nbsp; <batch:listener ref="jobPersonListener" />&nbsp; &nbsp; &nbsp; &nbsp; <batch:listener ref="personReadListener"/>&nbsp; &nbsp; </batch:listeners>&nbsp;</batch:job>应该改为&nbsp;<batch:job id="personJob">&nbsp; &nbsp; <batch:step id="step1bb1" >&nbsp; &nbsp; &nbsp; &nbsp; <batch:tasklet transaction-manager="transactionManager">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <batch:chunk reader="itemReader" writer="itemWriter"&nbsp; &nbsp;commit-interval="10" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <batch:listeners>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<batch:listener ref="jobPersonListener" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<batch:listener ref="personReadListener"/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </batch:listeners>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; </batch:tasklet>&nbsp; &nbsp; </batch:step></batch:job>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java