Vaibs
Vaibs

Reputation: 1606

Spring Batch::How to generate file on sftp server using Spring Batch?

I am using Spring Batch 2. version.I have generated the csv file and able to save in csv format on local.

Now I want to generate the same file but it will be stored on SFTP server.

I had gone through some tutorial which generates file on sftp server but they are using spring integration with Spring Batch.

Is it possible to generate the file on SFTP server using Spring Batch only?

Below is itemReader bean defined::

<bean id="itemReader"
        class="org.springframework.batch.item.database.JdbcCursorItemReader"
        scope="step">
        <property name="dataSource" ref="dataSource" />
        <property name="sql"
            value="select u.ID, u.USER_LOGIN, u.PASSWORD, u.AGE from USERS u" />
        </property>
        <property name="rowMapper">
            <bean class="com.example.UserRowMapper" />
        </property>
    </bean>

ItemWriter Bean::

<bean id="flatFileItemWriter" class="org.springframework.batch.item.file.FlatFileItemWriter">
        <property name="resource" value="file:csv/user.csv" />

        <property name="appendAllowed" value="true" />
        <property name="lineAggregator">
            <bean           class="org.springframework.batch.item.file.transform.DelimitedLineAggregator">
                <property name="delimiter" value="," />
                <property name="fieldExtractor">
                    <bean
                        class="org.springframework.batch.item.file.transform.BeanWrapperFieldExtractor">
                        <property name="names" value="name,age,id,password"/>
                        </bean>
        </property>
    </bean>

Upvotes: 2

Views: 1287

Answers (1)

LONGHORN007
LONGHORN007

Reputation: 546

You have to customize your writer class

Upvotes: 0

Related Questions