DolphinScheduler 3.2.0 后端开发环境搭建指南

发布于:2025-07-07 ⋅ 阅读:(17) ⋅ 点赞:(0)

目录

一、环境准备

二、源码获取

三、源码编译问题解决

四、关键配置修改

五、服务启动


一、环境准备
  1. 必需软件

    • JDK 8(必须使用 JDK 8)

    • Maven 3.6.0+(必须 ≥3.6.0

    • Git

    • MySQL 5.7+

  2. 版本验证

    java -version  # 必须显示 java version "1.8.x"
    mvn -v         # 必须显示 Apache Maven 3.6.0+
二、源码获取
  1. 克隆仓库并切换分支:

    git clone git@github.com:apache/dolphinscheduler.git
    cd dolphinscheduler
    git checkout 3.2.0  # 必须精确切换到3.2.0分支
三、源码编译问题解决
  1. 首次编译命令

    mvn clean install -Prelease -Dmaven.test.skip=true
  2. 问题1:Spotless格式检查失败 问题现象: 编译失败,控制台显示:

    [ERROR] Failed to execute goal com.diffplug.spotless:spotless-maven-plugin:2.27.2:check
    [ERROR] The following files had format violations:
    [ERROR]     pom.xml
    [ERROR]         @@ -15,7 +15,8 @@
    [ERROR]          ··~·See·the·License·for·the·specific·language·governing·permissions·and
    [ERROR]          ··~·limitations·under·the·License.
    [ERROR]          ··-->
    [ERROR]         -<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">
    [ERROR]         +<project·xmlns="http://maven.apache.org/POM/4.0.0"·xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    [ERROR]         +·········xsi:schemaLocation="http://maven.apache.org/POM/4.0.0·http://maven.apache.org/xsd/maven-4.0.0.xsd">

    问题原因pom.xml 文件的XML格式不符合规范,Spotless插件强制要求xsi:schemaLocation属性换行显示

    解决方案

    ./mvnw spotless:apply  # 自动修复格式问题
  3. 问题2:Maven版本不兼容 问题现象: 使用Maven 3.5.0编译时失败,控制台显示:

    [ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.12.1:install-node-and-pnpm 
    [ERROR] The plugin com.github.eirslett:frontend-maven-plugin:1.12.1 requires Maven version 3.6.0

    问题原因: 前端编译插件frontend-maven-plugin强制要求Maven版本≥3.6.0

    解决方案: 升级Maven到3.6.0+版本

  4. 重新编译

    mvn clean install -Prelease -Dmaven.test.skip=true
四、关键配置修改
  1. MySQL驱动作用域修改 文件dolphinscheduler-bom/pom.xml 修改点

    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <!-- 将scope从test改为compile -->
      <scope>compile</scope>
    </dependency>

    原因:确保编译时包含MySQL驱动

    紧接着创建dolphinscheduler数据库,并且dolphinscheduler/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sqlSQL文件直接在新创建的数据库中执行,初始化数据库。

  2. Master服务配置

    • 数据库配置dolphinscheduler-master/src/main/resources/application.yaml

      spring: 
        datasource:
          driver-class-name: com.mysql.cj.jdbc.Driver
          url: jdbc:mysql://127.0.0.1:3306/dolphinscheduler
          username: root
          password: mysql
    • 日志配置dolphinscheduler-master/src/main/resources/logback-spring.xml<root>节点内添加:

      <appender-ref ref="STDOUT"/>  <!-- 添加此行才能在控制台看到日志 -->
  3. Worker服务配置

    • 日志配置dolphinscheduler-worker/src/main/resources/logback-spring.xml 添加相同配置:

      <appender-ref ref="STDOUT"/>
  4. API服务配置

    • 数据库配置dolphinscheduler-api/src/main/resources/application.yaml

      spring: 
        datasource:
          driver-class-name: com.mysql.cj.jdbc.Driver
          url: jdbc:mysql://127.0.0.1:3306/dolphinscheduler
          username: root
          password: mysql
    • 日志配置dolphinscheduler-api/src/main/resources/logback-spring.xml 添加:

      <appender-ref ref="STDOUT"/>
五、服务启动
  1. 启动Master

    • 类路径:org.apache.dolphinscheduler.server.master.MasterServer

  2. 启动Worker

    • 类路径:org.apache.dolphinscheduler.server.worker.WorkerServer

  3. 启动API服务

    • 类路径:org.apache.dolphinscheduler.api.ApiApplicationServer


参考资料:DolphinScheduler环境搭建