大佬教程收集整理的这篇文章主要介绍了Spring Batch和Spring集成,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
绝对。您可以将JDBC ItemReader
或JPAItemReader
与一起使用,columnMapRowMapper
以检索@H_431_3@map结果集。您可以使用它FlatfileItemWriter
简单地以您喜欢的任何格式输出数据(使用提供的类很容易定界;固定宽度表示编写一个类以将转换@H_431_3@map为固定宽度字符串)。
我经常在Spring Batch中执行此操作,而这几乎只是布线的问题。
除了定义资源,数据源和提供sql之外,这种(未经测试的)配置几乎可以完全满足您的要求:
<?xml version="1.0" enCoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/scheR_288_11845@a/batch"
xmlns:beans="http://www.springframework.org/scheR_288_11845@a/beans" xmlns:aop="http://www.springframework.org/scheR_288_11845@a/aop"
xmlns:tx="http://www.springframework.org/scheR_288_11845@a/tx" xmlns:p="http://www.springframework.org/scheR_288_11845@a/p"
xmlns:xsi="http://www.w3.org/2001/XMLscheR_288_11845@a-instance" xmlns:util="http://www.springframework.org/scheR_288_11845@a/util"
xsi:scheR_288_11845@aLOCATIOn="
http://www.springframework.org/scheR_288_11845@a/beans http://www.springframework.org/scheR_288_11845@a/beans/spring-beans-2.0.xsd
http://www.springframework.org/scheR_288_11845@a/batch http://www.springframework.org/scheR_288_11845@a/batch/spring-batch-2.0.xsd
http://www.springframework.org/scheR_288_11845@a/aop http://www.springframework.org/scheR_288_11845@a/aop/spring-aop-2.0.xsd
http://www.springframework.org/scheR_288_11845@a/tx http://www.springframework.org/scheR_288_11845@a/tx/spring-tx-2.0.xsd
http://www.springframework.org/scheR_288_11845@a/util http://www.springframework.org/scheR_288_11845@a/util/spring-util-2.0.xsd">
<job-repository ID="jobRepository"
data-source="jobDatasource"/>
<beans:bean ID="transactionManager"
class="org.springframework.jdbc.datasource.DatasourcetransactionManager"
p:datasource-ref="jobDatasource" />
<beans:bean ID="extractReader" scope="step"
class="org.springframework.batch.item.database.JdbccursorItemReader">
<beans:property name="datasource" ref="apPDAtasource" />
<beans:property name="rowMapper">
<beans:bean
class="org.springframework.jdbc.core.columnMapRowMapper" />
</beans:property>
<beans:property name="sql">
<beans:value>
. . .
</beans:value>
</beans:property>
</beans:bean>
<beans:bean ID="extractWriter"
class="org.springframework.batch.item.file.FlatfileItemWriter" scope="step">
<beans:property name="resource" ref="fileresource" />
<beans:property name="lineAggregator">
<beans:bean
class="org.springframework.batch.item.file.transform.delimitedlineAggregator">
<beans:property name="delimiter">
<util:constant
static-fIEld="org.springframework.batch.item.file.transform.delimitedlinetokenizer.DEliMITER_TAB" />
</beans:property>
<beans:property name="fIEldExtractor">
<beans:bean
class="org.springframework.batch.item.file.transform.PassthroughFIEldExtractor" />
</beans:property>
</beans:bean>
</beans:property>
</beans:bean>
<job ID="extractJob" restartable="true">
<step ID="extractStep" >
<tasklet>
<chunk reader="extractReader" writer="extractWriter"
commit-interval="100" />
</tasklet>
</step>
</job>
</beans:beans>
我想使用Spring Batch和Spring Integration从数据库导入数据,并将它们写入文件,然后通过ftp将其传输到远程服务器。
但是我想我的问题是我不想为我的表创建域对象。我的查询是随机的,我想要一些可以读取数据并将其写入文件并进行传输的东西。
是否可以在不创建各自的域对象的情况下使用Spring Batch和Integration?
以上是大佬教程为你收集整理的Spring Batch和Spring集成全部内容,希望文章能够帮你解决Spring Batch和Spring集成所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。