简体   繁体   English

如何使用 Oracle 驱动程序依赖项自定义构建 Spring 云数据流服务器?

[英]How to do a Custom Build of Spring Cloud Data Flow server with Oracle driver dependency?

I've been trying out the SCDF for sometime with intention to use Oracle Database as datasource.我一直在尝试 SCDF 一段时间,打算使用 Oracle 数据库作为数据源。 Due to licensing issues Oracle driver has to be added to the classpath of SCDF server or we have to do a custom build of SCDF server with Oracle Driver dependency(Which I have).由于许可问题,必须将 Oracle 驱动程序添加到 SCDF 服务器的类路径中,或者我们必须使用 Oracle 驱动程序依赖项(我有)来自定义构建 SCDF 服务器。 When I download the custom build project dataflow-server-22x (only this project) from github and try to execute I get a missing artifact issue in pom.xml as below.当我从 github 下载自定义构建项目dataflow-server-22x (仅此项目)并尝试执行时,我在 pom.xml 中遇到了一个缺少工件的问题,如下所示。

Missing artifact io.pivotal:pivotal-cloudfoundry-client-reactor:jar:1.1.0.RELEASE 
at <xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> of pom.xml

So how exactly I have to perform the custom build of this SCDF jar. Am I missing something here?那么我究竟要如何执行这个 SCDF jar 的自定义构建。我在这里遗漏了什么吗?

Also my intention is just to build a jar containing set of batch jobs which can be deployed in SCDF and orchestrated from SCDF.此外,我的意图只是构建一个 jar,其中包含一组可以部署在 SCDF 中并从 SCDF 编排的批处理作业。 But I'm not using Docker or Kube.netes/CloudFoundry here.但我在这里没有使用 Docker 或 Kube.netes/CloudFoundry。

Note: I already asked one question to get clarification regarding this issue, which lead my to this issue.注意:我已经问了一个问题来澄清这个问题,这导致了我的这个问题。 There they said I should use custom build, But couldn't exactly tell how, or how to solve the issues arise from the custom build.他们在那里说我应该使用自定义构建,但无法确切说明如何或如何解决自定义构建引起的问题。 Hence I posted this question.因此我发布了这个问题。 SCDF+Oracle 民防部队+甲骨文

Thanks in advance.提前致谢。

Update 1:更新 1:

The above issue got resolved after Ilayaperumals suggestion.在 Ilayaperumals 的建议下,上述问题得到了解决。 However I got stuck up with another issue.但是我遇到了另一个问题。

org.springframework.context.ApplicationContextException: Failed to start bean 'taskLifecycleListener'; nested exception is java.lang.IllegalArgumentException: Invalid TaskExecution, ID 3 not found

But I see Id=3, in task_execution table after the I execute the task from SCDF.但是在我从 SCDF 执行任务后,我在 task_execution 表中看到 Id=3。 The custom SCDF project has the same database config property values as my Spring batch job properties.自定义 SCDF 项目具有与我的 Spring 批处理作业属性相同的数据库配置属性值。 Few things to note here are,这里需要注意的几件事是,

  • Spring-boot-starter-parent: 2.2.5.RELEASE, spring-boot-starter-parent:2.2.5.RELEASE,
  • Spring-cloud-dataflow: 2.2.0.RELEASE弹簧云数据流:2.2.0.RELEASE
  • I load all of my Batchjobs from main class of Boot using the instance of batch job class and only the main class (which kickstarts all jobs)contains @EnableTask annotation.我使用批处理作业 class 的实例从 Boot 的主要 class 加载我的所有 Batchjobs,只有主要的 class(它启动所有作业)包含 @EnableTask 注释。 Below is my class structure.下面是我的 class 结构。
    @SpringBootApplication
    @EnableScheduling
    @EnableTask
    public class SpringBootMainApplication{
        @Autowired
        Job1Loader job1Loader;

        public static void main(String[] args) {
            SpringApplication.run(SpringBootMainApplication.class, args);
        }

        @Scheduled(cron = "0 */1 * * * ?")
        public void executeJob1Loader() throws Exception
        {
            JobParameters param = new JobParametersBuilder()
                                        .addString("JobID",         
                                     String.valueOf(System.currentTimeMillis()))
                                        .toJobParameters();
            jobLauncher.run(job1Loader.loadJob1(), param);
        }
    }

    //Job Config
    @Configuration
    @EnableBatchProcessing
    public class Job1Loader {
    @Bean
        public Job loadJob1()
        {
            return jobBuilderFactory().get("JOb1Loader")
                .incrementer(new RunIdIncrementer())
                .flow(step01())
                .end()
                .build();;//return job
    }

I use two different datasources in my Spring job project, both are oracle datasource(Different servers).I marked one of them as primary and used that Datasource in my custom implementation of "DefaultTaskConfigurer" as below.我在我的 Spring 工作项目中使用了两个不同的数据源,都是 oracle 数据源(不同的服务器)。我将其中一个标记为主要数据源,并在我自定义的“DefaultTaskConfigurer”实现中使用了该数据源,如下所示。

    @Configuration
    public class TaskConfig extends DefaultTaskConfigurer {
        @Autowired
        DatabaseConfig databaseConfig; 
        @Override
        public DataSource getTaskDataSource() {
            return databaseConfig.dataSource();//dataSource() returns the 
    primary ds
        }
    }
  • Below are the properties I use in both SCDF custom serer and Spring Batch project.以下是我在 SCDF 自定义服务器和 Spring 批处理项目中使用的属性。
    **Spring batch Job :**
    spring.datasource.jdbc-url=jdbc:oracle:thin:@mydb
    spring.datasource.username=db_user
    spring.datasource.password=db_pwd
    spring.datasource.driver-class-name=oracle.jdbc.OracleDriver

    **SCDF customer Server:**
    spring.datasource.url=jdbc:oracle:thin:@mydb
    spring.datasource.username=db_user
    spring.datasource.password=db_pwd
    spring.datasource.driver-class-name=oracle.jdbc.OracleDriver

I tried supplying the db config as args while Starting the server and few other options like adding @Enabletask to all job config classes but none of them seems to work.我尝试在启动服务器时提供 db 配置作为 args 以及其他一些选项,例如将 @Enabletask 添加到所有作业配置类,但它们似乎都不起作用。

What am I missing here?我在这里错过了什么?

Since you mentioned you don't run this on CloudFoundry and the specific dependency io.pivotal:pivotal-cloudfoundry-client-reactor:jar comes from the spring-cloud-dataflow-platform-cloudfoundry , you need to remove this dependency from the custom build configuration as below:由于您提到您不在 CloudFoundry 上运行它并且特定依赖io.pivotal:pivotal-cloudfoundry-client-reactor:jar来自spring-cloud-dataflow-platform-cloudfoundry ,您需要从自定义中删除此依赖项构建配置如下:

                 <dependency>
                        <groupId>org.springframework.cloud</groupId>
                        <artifactId>spring-cloud-starter-dataflow-server</artifactId>
                        <exclusions>
                                        <exclusion>
                                                <groupId>org.springframework.cloud</groupId>
                                                <artifactId>spring-cloud-dataflow-platform-cloudfoundry</artifactId>
                                        </exclusion>
                                </exclusions>
                </dependency>

Also, doing ./mvnw dependency:tree will help you figure where does the dependency come from:此外,执行./mvnw dependency:tree将帮助您确定依赖项来自何处:

\- org.springframework.cloud:spring-cloud-dataflow-platform-cloudfoundry:jar:2.5.0.BUILD-SNAPSHOT:compile
[INFO] |  |        +- org.springframework.cloud:spring-cloud-deployer-cloudfoundry:jar:2.3.0.BUILD-SNAPSHOT:compile
[INFO] |  |        |  +- org.cloudfoundry:cloudfoundry-client-reactor:jar:4.1.0.RELEASE:compile
[INFO] |  |        |  | 
[INFO] |  |        |  +- io.projectreactor.addons:reactor-extra:jar:3.3.2.RELEASE:compile
[INFO] |  |        |  \- io.pivotal:pivotal-cloudfoundry-client-reactor:jar:2.0.0.RELEASE:compile
[INFO] |  |        |     \- io.pivotal:pivotal-cloudfoundry-client:jar:2.0.0.RELEASE:compile

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM