Java Reference
In-Depth Information
will obtain the entire Spring Batch Git repository. In order to get a particular version execute the
command in Listing 2-2 from within your checked out repository.
Listing 2-2. Getting a particular version of Spring Batch
$ git checkout 2.1.7.RELEASE
Con fi guring Maven
In order to use Maven for your builds, you need to tweak your local Maven installation slightly. The
Project Object Model (POM) files that are provided as part of the downloaded distributions for Spring
projects don't have the Spring Maven repositories configured in them. Because of that, you should add
them to your settings.xml file. Listing 2-3 shows the added configuration you need.
Listing 2-3. Getting the Repository DDL from SVN
<pluginRepositories>
<pluginRepository>
<id>com.springsource.repository.bundles.release</id>
<name>SpringSource Enterprise Bundle Repository</name>
<url>http://repository.springsource.com/maven/bundles/release</url>
</pluginRepository>
</pluginRepositories>
With the project shell created and Maven configured, you can test the configuration by running a quick
mvn clean install . With a successful build, you can move on to your first batch job.
It's the Law: Hello, World!
The laws of computer science are clear. Any time you learn a new technology, you must create a “Hello,
World!” program using said technology, so let's get started. Don't feel like you need to understand all the
moving parts of this example. Future chapters go into each piece in greater detail.
Before you get too far into the new code, you should do some clean up of files and references to
them that are not needed. These files, while being provided for examples, are not kept in a typical Spring
Batch project. To start, we can delete all of the java source code and tests. These are located in the
src/main/java and src/test/java directories. Once those are removed we can remove the module-
context.xml file. This is a sample job configuration that you will not need in your project. Finally, since
you removed a few java files that were referenced in the project's configuration, that needs to be
updated as well. In the file src/main/resources/launch-context.xml you will want to remove the import
at the top for the module-context.xml as well as the dataSourceInitializer bean at the bottom of the file.
The dataSourceIntializer will be looked at further in Chapter 12.
As discussed earlier, a job is configured in XML. To create your “Hello, World!” job, create a new
directory in src/main/resources called jobs; in the new directory, create an XML file called
helloWorld.xml, as shown in Listing 2-4.
Listing 2-4. The “Hello, World!” Job
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns =" http://www.springframework.org/schema/batch"
xmlns:beans=" http://www.springframework.org/schema/beans"
 
Search WWH ::




Custom Search