第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

當我運行 spring 批處理作業(yè)時,chunkListener 不運行

當我運行 spring 批處理作業(yè)時,chunkListener 不運行

哈士奇WWW 2021-07-28 16:46:27
我在 springBatch 作業(yè)中使用 checkListener 和 readListener 作為我用來學習 springbatch 的示例。但是當我運行作業(yè)時,chunkListener 不運行,只有 readListener 與作業(yè)一起運行。personChunkListener.java:     package sb.dbToxml;        import javax.batch.api.chunk.listener.ChunkListener;        public class PersonChunkListener implements ChunkListener        {          @Override          public void afterChunk() throws Exception          {            System.out.println("after chunk ....***************");          }          @Override          public void beforeChunk() throws Exception          {            System.out.println("before chunk ....***************");          }          @Override          public void onError(Exception arg0) throws Exception          {            // TODO Auto-generated method stub          }        }this is the configuration xml file for spring batch context spring-batch-context.xml :    <?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-3.2.xsd">        <import resource="../jobs/jobPerson.xml" />        <import resource="../config/spring-datasource.xml" />        <!-- <context:annotation-config /> <tx:annotation-driven transaction-manager="transactionManager"/>a             PlatformTransactionManager is still required -->        <!-- JobRepository and JobLauncher are configuration/setup classes -->        <bean id="jobRepository"            class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean">            <property name="dataSource" ref="dataSourceBatch" />            <property name="transactionManager" ref="transactionManager" />            <property name="databaseType" value="oracle" />        </bean>
查看完整描述

1 回答

?
BIG陽

TA貢獻1859條經驗 獲得超6個贊

該ChunkListener是有關chunk的配置,因此它需要內部被定義chunk這樣的標簽:


<batch:job id="personJob">

    <batch:step id="step1bb1" >

        <batch:tasklet transaction-manager="transactionManager">

            <batch:chunk reader="itemReader" writer="itemWriter" commit-interval="10" >

               <batch:listeners>

                  <batch:listener ref="chunkListener"/>

               </batch:listeners>

            </batch:chunk>

        </batch:tasklet>

    </batch:step>

    <batch:listeners>

           <batch:listener ref="jobPersonListener" />

    </batch:listeners> 

</batch:job>

此外,您PersonChunkListener實現(xiàn)了javax.batch.api.chunk.listener.ChunkListener接口,但它應該實現(xiàn)org.springframework.batch.core.ChunkListener。


查看完整回答
反對 回復 2021-08-04
  • 1 回答
  • 0 關注
  • 506 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號