在嵌入式tomcat中使用Spring云数据流运行Spring Batch Web应用程序

时间:2018-01-02 11:27:44

标签: spring-boot spring-cloud-dataflow spring-cloud-task

我们可以运行Spring Batch基于Web的应用程序,并集成了Spring云数据流吗? 我试图将SCDF集成到现有的基于Web的弹簧批处理项目中。 这是我的pom.xml文件

  <?xml version="1.0" encoding="UTF-8"?>
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.TSpringBatch</groupId>
<artifactId>TSpringBatch</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>TSpringBatch</name>
<description>TSpringBatch</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.9.RELEASE</version>
    <relativePath /> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
    <spring-cloud-task.version>1.2.2.RELEASE</spring-cloud-task.version>
    <start-class>com.TSpringBatch.TSpringBatchApplication</start-class>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.batch</groupId>
        <artifactId>spring-batch-core</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-task-core</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.batch</groupId>
        <artifactId>spring-batch-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>com.zaxxer</groupId>
        <artifactId>HikariCP</artifactId>
        <version>2.7.2</version>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.16.16</version>
    </dependency>
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.8.2</version>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>6.0.6</version>
    </dependency>
</dependencies>
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-task-dependencies</artifactId>
            <version>${spring-cloud-task.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

我的主要课程用@EnableTask注释

    package com.TSpringBatch;

    import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.cloud.task.configuration.EnableTask;

    @SpringBootApplication
    @EnableBatchProcessing
    @EnableTask
    public class TSpringBatchApplication {
        public static void main(String[] args) {
            SpringApplication.run(TSpringBatchApplication.class, args);
        }
    }

如果我运行该应用程序。我得到一条日志消息,

o.s.b.c.e.AnnotationConfigEmbeddedWebApplicationContext -                 关闭org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5fe94a96:启动日期[Tue Jan 02 16:43:56 IST 2018];上下文层次结构的根

所以我的应用程序没有在嵌入式tomcat中运行。如果我删除@EnableTask注释,很可惜它的工作原理。请帮助我解决问题

1 个答案:

答案 0 :(得分:0)

Spring Cloud数据流不是为嵌入现有应用程序而构建的。它是一个独立的服务器,旨在用作独立的应用程序。