User Tools

Site Tools


spring_batch

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
spring_batch [2013/11/05 13:48]
mihael
spring_batch [2015/03/17 08:38]
mihael
Line 83: Line 83:
 </​beans:​bean>​ </​beans:​bean>​
 </​sxh>​ </​sxh>​
 +
 +==== Tab Delimited Values ====
 +To declare the tab character as a delimiter "​\t"​ cannot be specified. Instead use the Java constant from the Spring framework.
 +
 +<sxh xml>
 +  <​beans:​property name="​lineTokenizer">​
 +    <​beans:​bean class="​org.springframework.batch.item.file.transform.DelimitedLineTokenizer">​
 +      <!-- field delimiter of your csv file -->
 +      <​beans:​property name="​delimiter">​
 +        <​util:​constant static-field="​org.springframework.batch.item.file.transform.DelimitedLineTokenizer.DELIMITER_TAB"/>​
 +      </​beans:​property>​
 +    </​beans:​bean>​
 +  </​beans:​property>​
 +</​sxh>​
 +
 +Don't forget to add the namespance to the head of the xml file.
 +
 +<sxh xml>
 +<​beans:​beans xmlns:​beans="​http://​www.springframework.org/​schema/​beans"​
 + xmlns:​xsi="​http://​www.w3.org/​2001/​XMLSchema-instance"​ xmlns:​jdbc="​http://​www.springframework.org/​schema/​jdbc"​
 + xmlns:​batch="​http://​www.springframework.org/​schema/​batch"​
 + xmlns:​util="​http://​www.springframework.org/​schema/​util"​
 + xmlns:​context="​http://​www.springframework.org/​schema/​context"​ xmlns:​p="​http://​www.springframework.org/​schema/​p"​
 + xsi:​schemaLocation="​
 +          http://​www.springframework.org/​schema/​batch http://​www.springframework.org/​schema/​batch/​spring-batch-2.2.xsd
 +          http://​www.springframework.org/​schema/​beans http://​www.springframework.org/​schema/​beans/​spring-beans-3.1.xsd
 +          http://​www.springframework.org/​schema/​jdbc http://​www.springframework.org/​schema/​jdbc/​spring-jdbc-3.1.xsd
 +          http://​www.springframework.org/​schema/​util http://​www.springframework.org/​schema/​util/​spring-util-3.0.xsd
 +          http://​www.springframework.org/​schema/​context http://​www.springframework.org/​schema/​context/​spring-context-3.1.xsd">​
 +</​sxh>​
 +
 +
 +
 +===== Create Jar with Dependencies =====
 +To embed all dependencies and create an executable jar the pom.xml must be extended by the maven-assenbly-plugin.
 +
 +<sxh xml>
 +    <​build>​
 + <​plugins>​
 + <​plugin>​
 + <​artifactId>​maven-assembly-plugin</​artifactId>​
 + <​configuration>​
 + <​archive>​
 + <​manifest>​
 + <​mainClass>​
 + org.springframework.batch.core.launch.support.CommandLineJobRunner
 + </​mainClass>​
 + </​manifest>​
 + </​archive>​
 + <​descriptorRefs>​
 + <​descriptorRef>​jar-with-dependencies</​descriptorRef>​
 + </​descriptorRefs>​
 + </​configuration>​
 + </​plugin>​
 + </​plugins>​
 + </​build>​
 +</​sxh>​
 +
 +Create the jar with executing the following line on the command line
 +
 +  mvn clean compile assembly:​single
 +  ​
 +Execute the program with
 +
 +  java -jar program-jar-with-dependencies.jar launch-context.xml jobid
 +
 +{{tag>​devel java}}
spring_batch.txt ยท Last modified: 2015/03/17 08:38 by mihael