1

The case is that I have launched both Spring Cloud Data Flow Server and Shell apps in my local machine, and they all used the H2 memory database to store the tasks and jobs defination.

When I deployed the application that Used a H2 as the database to read data, it works perfect fine.

But when I want to deploy and run the application that read data from a local postgresql database, it just could not find it, and will then use the H2 again.

I have add postgresql dependency in my pom and also configure the properties in the application.properties , it works fine with spring batch in my local Intelij.

So my question is that how could I make my application still read data from the postgresql after it been deployed in the spring-cloud-data-flow-server? Thanks.

Configuration info:

        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.0.0.RELEASE</version>
        </parent>

        <properties>
            <java.version>1.8</java.version
         <spring.cloud.task.version>2.0.0.RELEASE</spring.cloud.task.version>
        </properties>

        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-batch</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-task-core</artifactId>
                <version>${spring.cloud.task.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-task-batch</artifactId>
                <version>${spring.cloud.task.version}</version>
            </dependency>
Ray
  • 477
  • 1
  • 6
  • 18

1 Answers1

1

You can control what datasource should be configured to SCDF, Tasks, Task-launcher, and even Composed Task Runner. The documentation for these options could be useful.

In your case, though, it sounds like you have 2 different databases: one for SCDF and the other for the Task that SCDF launches, which should be a pretty straightforward setup as long as the datasource properties are configured correctly on both the Boot apps.

It could be that either there's no Postgres driver in the classpath or the datasource properties aren't configured correctly. Review the docs of the connection properties for the supported databases - you could double check for correctness.

Sabby Anandan
  • 5,636
  • 2
  • 12
  • 21
  • Hi Sabby, Thanks for your answer, it is some configuration error, I have fixed it with the help of the spring document – Ray Dec 18 '18 at 07:47
  • Could you tell me what the error and the exact solutions was? I'm in the same situation (want task with its own database) but I can't find the proper answer and I've been searching for it everywhere for hours. – S0m30n3 Mar 07 '19 at 14:45
  • Created my own question with some specifics: https://stackoverflow.com/questions/55047310/configuring-a-spring-cloud-data-flow-task-with-its-own-database – S0m30n3 Mar 07 '19 at 15:26
  • 1
    @S0m30n3 please refer this sample provided by the spring:https://github.com/spring-cloud/spring-cloud-task/blob/master/spring-cloud-task-samples/multiple-datasources/src/main/java/io/spring/configuration/CustomTaskConfigurer.java – Ray Mar 18 '19 at 07:43