Class SpringBootBatchCommandLine


  • @Deprecated
    public class SpringBootBatchCommandLine
    extends Object
    Deprecated.
    Since spring batch and spring boot are nicely integrated it is possible to start batches without any custom launcher. This is documented in the current devonfw batch documentation. This launcher is no longer required and will be removed in one of the next releases.
    Launcher for launching batch jobs from the command line when Spring Boot is used. It is somewhat similar to the CommandLineJobRunner. The main difference is, that this launcher disables the web-app for the spring context. It expects the full class name of the Spring Boot configuration class to be used as first argument and the jobs beanname as the second.
    Moreover parameters can be specified as further arguments (convention: key1=value1 key2=value2 ...).

    Example:
    java -jar my-app-batch-bootified.jar com.devonfw.application.example.SpringBootApp myJob param=value...

    For stopping all running executions of a job, use the -stop option. Example:
    java -jar my-app-batch-bootified.jar com.devonfw.application.example.SpringBootApp myJob -stop

    To make that work expect that the batchs is deployed in form of a "bootified" jar, whith this class here als the start-class. For that you have to add the following snipped to your pom.xml:

     
     <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <configuration>
              <excludes>
                <exclude>config/application.properties</exclude>
              </excludes>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
              <mainClass>com.devonfw.module.batch.common.base.SpringBootBatchCommandLine</mainClass>
              <classifier>bootified</classifier>
            </configuration>
            <executions>
              <execution>
                <goals>
                  <goal>repackage</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
     
     

    • Constructor Detail

      • SpringBootBatchCommandLine

        public SpringBootBatchCommandLine()
        Deprecated.
    • Method Detail

      • main

        public static void main​(String[] args)
                         throws Exception
        Deprecated.
        Parameters:
        args - the command-line arguments.
        Throws:
        Exception - in case of an error.
      • getReturnCode

        protected int getReturnCode​(org.springframework.batch.core.JobExecution jobExecution)
        Deprecated.
        Parameters:
        jobExecution - the JobExecution.
        Returns:
        the corresponding exit code.
      • execute

        public void execute​(SpringBootBatchCommandLine.Operation operation,
                            String configuration,
                            String jobName,
                            List<String> parameters)
                     throws Exception
        Deprecated.
        Initialize the application context and execute the operation.

        The application context is closed after the operation has finished.

        Parameters:
        operation - The operation to start.
        configuration - The sources of app context configuration.
        jobName - The name of the job to launch/stop.
        parameters - The parameters (key=value).
        Throws:
        Exception - in case of an error.