首页 > 解决方案 > 如何验证 Reader 中的参数以进行查询

问题描述

我需要在阅读器中验证我的查询的参数,我在 RunConfiguration 中发送参数,我给你我的代码工作,感谢你的帮助(我用“*”谴责部分代码用于数据保护)

<bean class="**.*****.absis.batch.arch.internal.reader.***ItemReader" id="readerBBDD_Step1">
    <property name="dataSource" ref="appDataSource"></property>
    <property name="sql" value="select conf.repte, imp.IMPREPTE1 , imp.IMPREPTE2, imp.IMPREPTE3,imp.IMPREPTE4,imp.IMPREPTE5,imp.IMPREPTE6, subrepte, negocio, asignacion, tipus, origen  from **************BATCH0003 conf inner join 
TDE_IMPORTREPTES_BATCH0003 imp on CONF.REPTE = imp.repte 
where conf.anyo = imp.anyo and conf.repte = '****' and esquema = '*****' and tipus='${param1}'" ></property>    
    <property name="rowMapper">
        <bean class="****.****.absis.batch.arch.internal.reader.****sBaseRowMapper">
            <property name="rowMapper">
                <bean class="***.***.absis.batch.app.****.util.MapperStep1"></bean>
            </property>
        </bean>
    </property>
</bean>

我的目标是控制参数1

标签: spring-batch

解决方案


我在 RunConfiguration 中发送参数

您可以将param1作为参数传递给您的作业并使用JobParametersValidator.

然后,一旦它被验证,它可以通过以下方式传递给您的读者:

tipus='#{jobParameters[param1]}'

希望这可以帮助。


推荐阅读