使用自己的数据库配置 Spring Cloud 数据流任务 [英] Configuring a Spring Cloud Data Flow Task with its own Database

查看:42
本文介绍了使用自己的数据库配置 Spring Cloud 数据流任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有自己数据库的任务应用程序,我想在 Spring Cloud Data Flow 中运行该应用程序.

I have a task application with its own database that I'd like to run in Spring Cloud Data Flow.

我的问题是 SCDF 用 SCDF 的数据源配置覆盖了任务中的数据源配置.(两个数据库都是 Oracle DB.)

My problem is that SCDF overwrites the datasource configuration in the task with the datasource configuration for SCDF. (Both databases are Oracle DBs.)

我的任务应该写入不同的数据库(但我也想知道它在 SCDF 数据库中的状态).

My task should write to a different database (but I also want to know its status in SCDF database).

如何配置我的任务以连接到它自己的数据库以及 SCDF 的数据库?

How is it possible to configure my task to connect to its own database as well as to SCDF's database?

推荐答案

我找到了解决方案.

我在一个配置类中定义了两个数据源(一个用于 JPA,一个用于 SCDF),下面作为示例:https://www.baeldung.com/spring-data-jpa-multiple-databases

I defined both data sources in a configuration class (one for JPA and one for SCDF) following this as an example: https://www.baeldung.com/spring-data-jpa-multiple-databases

然而这还不够,因为数据流服务器默认只接受一个数据源.为了克服这一点,需要扩展DefaultTaskConfigurer并在构造函数中设置数据流服务器的数据源.

However this wasn't enough because the Data Flow Server accepts only one data source by default. To overcome this, one needs to extend the DefaultTaskConfigurer and set the Data Flow Server's data source in the constructor.

@Component
public class GeneratorTaskConfigurer extends DefaultTaskConfigurer {

    public GeneratorTaskConfigurer(@Qualifier("dataflowDataSource") DataSource dataSource) {
        super(dataSource);
    }
}

这篇关于使用自己的数据库配置 Spring Cloud 数据流任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆