Java Reference
In-Depth Information
Basic Job Configuration
Listing 4-1 shows the shell of a basic Spring Batch job. For the record, this isn't a valid job. A job in
Spring Batch is required to have at least one step or be declared abstract. 3 In any case, the focus here is
on the job and not the steps, so you add steps to the job later in this chapter.
You used this format in Chapter 2's “Hello, World!” job, and it should look familiar to anyone who
has used Spring before. Just like most other extensions of the Spring framework, you configure beans like
any other use of Spring and have an XSD that defines domain-specific tags. In this case, you include the
XSD for Spring Batch in the beans tag.
Listing 4-1. basicJob.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:batch=""
<import resource="../launch-context.xml"/>
<batch:job id="basicJob">
The first piece of the basicJob.xml file after the beans tag is an import for the launch-context.xml
file, which is located in the src/main/resources directory of your project. You used this file in Chapter 2
without really going into it, so let's look at it now. Listing 4-2 shows launch-context.xml . Notice that this
launch-context.xml is a significantly slimmed-down version of what came out of the zip file. This topic
discusses the rest of the file as you use its parts in future chapters. For now, let's focus on the pieces that
you need to make Spring Batch work.
Listing 4-2. launch-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${batch.jdbc.driver}" />
<property name="url" value="${batch.jdbc.url}" />
<property name="username" value="${batch.jdbc.user}" />
3 Later, this chapter looks at abstract jobs.
Search WWH ::

Custom Search