EBEasyBuild Docs
文档/后端/BOM

easyfk-dependencies 使用手册

统一依赖版本管理平台(BOM)阅读时间 ~15 min

1. 简介

easyfk-dependencies 是 EasyFK 体系的统一依赖版本管理平台(BOM),发布坐标为:

plaintext
com.mcst:easyfk-dependencies

引入该 BOM 后,下游业务项目无需逐一声明依赖版本号,即可获得经过验证的、一致的依赖版本基线,避免多项目间版本漂移与冲突。

核心价值

  • 统一管控 EasyFK 内部模块、Spring 生态及常用第三方库的版本。
  • 下游项目只需引入一个 BOM 坐标,按需声明依赖即可,无需关心版本号。
  • 升级时只需更新 BOM 版本,所有受管依赖自动对齐。
注意
JDK 要求:Spring Boot 3.x 要求 JDK 17+,请确保项目编译与运行环境满足此要求。

2. 快速接入

TIP
以下示例中 ${easyfk.version} 代表实际使用的 BOM 版本号,请替换为项目所需的具体版本。

2.1 Gradle 项目

build.gradle 中通过 platform 引入 BOM:

gradle
repositories {
    // 配置公司私服地址(根据实际情况修改)
    maven { url 'https://your-nexus-host/repository/maven-public/' }
}

dependencies {
    // 引入 BOM,统一版本管理
    implementation platform('com.mcst:easyfk-dependencies:${easyfk.version}')

    // 之后引入依赖无需写版本号
    implementation 'com.mcst:easyfk-core'
    implementation 'com.mcst:service-base'
    implementation 'com.mcst:web-common'
}

如果需要强制所有传递依赖也受 BOM 约束,可使用 enforcedPlatform

gradle
dependencies {
    implementation enforcedPlatform('com.mcst:easyfk-dependencies:${easyfk.version}')
}

Gradle Kotlin DSL 写法:

kotlin
dependencies {
    implementation(platform("com.mcst:easyfk-dependencies:${easyfk.version}"))

    implementation("com.mcst:easyfk-core")
    implementation("com.mcst:service-base")
}

2.2 Maven 项目

pom.xml<dependencyManagement> 中以 BOM 方式引入:

xml
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.mcst</groupId>
            <artifactId>easyfk-dependencies</artifactId>
            <version>${easyfk.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

之后在 <dependencies> 中引入具体依赖时无需声明版本号:

xml
<dependencies>
    <dependency>
        <groupId>com.mcst</groupId>
        <artifactId>easyfk-core</artifactId>
    </dependency>
    <dependency>
        <groupId>com.mcst</groupId>
        <artifactId>service-base</artifactId>
    </dependency>
    <dependency>
        <groupId>com.mcst</groupId>
        <artifactId>web-common</artifactId>
    </dependency>
</dependencies>

3. BOM 管控范围

3.1 框架级 BOM

本 BOM 内部已引入以下框架级 BOM,下游项目无需重复引入

  • spring-boot-dependencies
  • spring-cloud-dependencies
  • spring-cloud-alibaba-dependencies

3.2 EasyFK 核心模块

坐标(artifactId)说明
easyfk-core核心基础模块
easyfk-authority权限模块
easyfk-thread线程管理模块
easyfk-cache缓存抽象模块
easyfk-doc文档模块
easyfk-lock分布式锁抽象模块
easyfk-mq消息队列抽象模块
easyfk-repository数据仓储模块
easyfk-resource资源模块

3.3 EasyFK 服务模块

坐标说明
service-api服务 API 定义
service-base服务基础模块

3.4 EasyFK Web 模块

坐标说明
web-commonWeb 公共模块
web-micro微服务 Web 模块
web-prd生产环境 Web 模块
web-baseWeb 基础模块
web-simple简单 Web 模块

3.5 数据库与数据源

坐标说明
com.mcst:db-mysqlEasyFK MySQL 封装
com.mcst:db-postgresqlEasyFK PostgreSQL 封装
com.mcst:db-redisEasyFK Redis 封装
com.mcst:db-mongoEasyFK MongoDB 封装
com.mcst:db-influxEasyFK InfluxDB 封装
com.mysql:mysql-connector-jMySQL 驱动
org.postgresql:postgresqlPostgreSQL 驱动
org.mongodb:mongo-java-driverMongoDB 驱动
com.influxdb:influxdb-client-javaInfluxDB 客户端
com.alibaba:druid-spring-boot-starterDruid 连接池
com.mcst:datasource-druidEasyFK Druid 封装
shardingsphere-jdbc-core-spring-boot-starterShardingSphere 分库分表

3.6 ORM 框架

坐标说明
com.mcst:orm-mybatisEasyFK MyBatis 封装
com.mcst:orm-flexEasyFK MyBatis-Flex 封装
com.mcst:orm-hibernateEasyFK Hibernate 封装
com.mcst:orm-shardingEasyFK 分片 ORM 封装
mybatis-plus-spring-boot3-starterMyBatis-Plus
dynamic-datasource-spring-boot3-starter动态数据源

3.7 缓存

坐标说明
com.mcst:cache-redisRedis 缓存实现
com.mcst:cache-caffeineCaffeine 缓存实现
com.mcst:cache-mult多级缓存实现
com.github.ben-manes.caffeine:caffeineCaffeine
org.redisson:redissonRedisson

3.8 分布式锁

坐标说明
com.mcst:lock-redissonRedisson 分布式锁
com.mcst:lock-zkZooKeeper 分布式锁

3.9 消息队列

坐标说明
com.mcst:mq-commonMQ 公共模块
com.mcst:mq-kafkaKafka 实现
com.mcst:mq-rocketRocketMQ 实现
com.mcst:mq-rabbitRabbitMQ 实现
com.mcst:mq-xxlXXL-MQ 实现
rocketmq-spring-boot-starterRocketMQ Starter

3.10 微服务组件

坐标说明
com.mcst:registry-nacosNacos 注册中心
com.mcst:config-nacosNacos 配置中心
com.mcst:protect-sentinelSentinel 流量防护
com.mcst:gateway-gateway网关模块
com.mcst:rpc-cloudSpring Cloud RPC
com.mcst:rpc-dubboDubbo RPC
com.mcst:remote-cloudCloud 远程调用
com.mcst:remote-dubboDubbo 远程调用
com.mcst:transaction-seataSeata 分布式事务
dubbo-spring-boot-starterDubbo Starter
dubbo-registry-nacosDubbo Nacos 注册

3.11 日志

坐标说明
com.mcst:log-log4j2EasyFK Log4j2 封装
com.mcst:log-logbackEasyFK Logback 封装
logstash-logback-encoderLogstash 日志编码器
apm-toolkit-log4j-2.xSkyWalking Log4j2
apm-toolkit-logback-1.xSkyWalking Logback

3.12 文档 / API

坐标说明
com.mcst:doc-knife4jEasyFK Knife4j 封装
com.mcst:doc-micro微服务文档模块
knife4j-openapi3-jakarta-spring-boot-starterKnife4j OpenAPI3
io.swagger.core.v3:swagger-annotationsSwagger 注解

3.13 工具与扩展

坐标说明
com.mcst:tool-httpHTTP 工具
com.mcst:tool-excelExcel 工具
com.mcst:component-autoId自增 ID 组件
com.mcst:job-xxlXXL-Job 封装
com.xuxueli:xxl-job-coreXXL-Job
com.xuxueli:xxl-mq-coreXXL-MQ
com.xuxueli:xxl-cache-coreXXL-Cache
mapstruct-plus-spring-boot-starterMapStruct Plus
com.alibaba:easyexcelEasyExcel
com.squareup.okhttp3:okhttpOkHttp

3.14 第三方基础库

坐标说明
com.alibaba.fastjson2:fastjson2FastJSON2
com.esotericsoftware:kryoKryo 序列化
org.slf4j:slf4j-apiSLF4J API
org.projectlombok:lombokLombok
cn.hutool:hutool-allHutool 工具集
jasypt-spring-boot-starterJasypt 配置加密

3.15 WebSocket

坐标说明
com.mcst:websocket-apiWebSocket API
com.mcst:websocket-serverWebSocket 服务端

3.16 存储组件

坐标说明
com.mcst:queue-disruptorDisruptor 队列
com.mcst:storage-chronicleChronicle 存储
com.mcst:chronicle-mapChronicle Map 封装
com.mcst:chronicle-queueChronicle Queue 封装
net.openhft:chronicle-mapChronicle Map
net.openhft:chronicle-queueChronicle Queue

3.17 微信开发

坐标说明
wx-java-miniapp-spring-boot-starter小程序
wx-java-mp-spring-boot-starter公众号
wx-java-pay-spring-boot-starter微信支付
wx-java-cp-spring-boot-starter企业微信

3.18 ClickHouse

坐标说明
com.clickhouse:clickhouse-jdbcClickHouse JDBC
httpcomponents.client5:httpclient5HttpClient5
httpcomponents.core5:httpcore5HttpCore5

3.19 资源服务

坐标说明
com.mcst:resource-server资源服务端
com.mcst:resource-repository-api资源仓库 API
com.mcst:resource-repository-mybatis资源仓库 MyBatis 实现
com.mcst:resource-sc-client资源 SC 客户端
com.mcst:resource-sc-provider资源 SC 服务端

4. 典型使用场景

4.1 单体 Web 应用

Gradle:

gradle
dependencies {
    implementation platform('com.mcst:easyfk-dependencies:${easyfk.version}')

    implementation 'com.mcst:easyfk-core'
    implementation 'com.mcst:web-base'
    implementation 'com.mcst:orm-mybatis'
    implementation 'com.mcst:db-mysql'
    implementation 'com.mcst:cache-redis'
    implementation 'com.mcst:log-logback'

    compileOnly 'org.projectlombok:lombok'
    annotationProcessor 'org.projectlombok:lombok'
}

Maven:

xml
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.mcst</groupId>
            <artifactId>easyfk-dependencies</artifactId>
            <version>${easyfk.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>com.mcst</groupId>
        <artifactId>easyfk-core</artifactId>
    </dependency>
    <dependency>
        <groupId>com.mcst</groupId>
        <artifactId>web-base</artifactId>
    </dependency>
    <dependency>
        <groupId>com.mcst</groupId>
        <artifactId>orm-mybatis</artifactId>
    </dependency>
    <dependency>
        <groupId>com.mcst</groupId>
        <artifactId>db-mysql</artifactId>
    </dependency>
    <dependency>
        <groupId>com.mcst</groupId>
        <artifactId>cache-redis</artifactId>
    </dependency>
    <dependency>
        <groupId>com.mcst</groupId>
        <artifactId>log-logback</artifactId>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <scope>provided</scope>
    </dependency>
</dependencies>

4.2 微服务应用(Nacos + Dubbo)

Gradle:

gradle
dependencies {
    implementation platform('com.mcst:easyfk-dependencies:${easyfk.version}')

    implementation 'com.mcst:easyfk-core'
    implementation 'com.mcst:web-micro'
    implementation 'com.mcst:service-base'
    implementation 'com.mcst:registry-nacos'
    implementation 'com.mcst:config-nacos'
    implementation 'com.mcst:rpc-dubbo'
    implementation 'com.mcst:protect-sentinel'
    implementation 'com.mcst:orm-mybatis'
    implementation 'com.mcst:db-mysql'
    implementation 'com.mcst:cache-redis'
    implementation 'com.mcst:doc-knife4j'
}

Maven:

xml
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.mcst</groupId>
            <artifactId>easyfk-dependencies</artifactId>
            <version>${easyfk.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>com.mcst</groupId>
        <artifactId>easyfk-core</artifactId>
    </dependency>
    <dependency>
        <groupId>com.mcst</groupId>
        <artifactId>web-micro</artifactId>
    </dependency>
    <dependency>
        <groupId>com.mcst</groupId>
        <artifactId>service-base</artifactId>
    </dependency>
    <dependency>
        <groupId>com.mcst</groupId>
        <artifactId>registry-nacos</artifactId>
    </dependency>
    <dependency>
        <groupId>com.mcst</groupId>
        <artifactId>config-nacos</artifactId>
    </dependency>
    <dependency>
        <groupId>com.mcst</groupId>
        <artifactId>rpc-dubbo</artifactId>
    </dependency>
    <dependency>
        <groupId>com.mcst</groupId>
        <artifactId>protect-sentinel</artifactId>
    </dependency>
    <dependency>
        <groupId>com.mcst</groupId>
        <artifactId>orm-mybatis</artifactId>
    </dependency>
    <dependency>
        <groupId>com.mcst</groupId>
        <artifactId>db-mysql</artifactId>
    </dependency>
    <dependency>
        <groupId>com.mcst</groupId>
        <artifactId>cache-redis</artifactId>
    </dependency>
    <dependency>
        <groupId>com.mcst</groupId>
        <artifactId>doc-knife4j</artifactId>
    </dependency>
</dependencies>

4.3 网关服务

Gradle:

gradle
dependencies {
    implementation platform('com.mcst:easyfk-dependencies:${easyfk.version}')

    implementation 'com.mcst:gateway-gateway'
    implementation 'com.mcst:registry-nacos'
    implementation 'com.mcst:config-nacos'
    implementation 'com.mcst:protect-sentinel'
}

Maven:

xml
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.mcst</groupId>
            <artifactId>easyfk-dependencies</artifactId>
            <version>${easyfk.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>com.mcst</groupId>
        <artifactId>gateway-gateway</artifactId>
    </dependency>
    <dependency>
        <groupId>com.mcst</groupId>
        <artifactId>registry-nacos</artifactId>
    </dependency>
    <dependency>
        <groupId>com.mcst</groupId>
        <artifactId>config-nacos</artifactId>
    </dependency>
    <dependency>
        <groupId>com.mcst</groupId>
        <artifactId>protect-sentinel</artifactId>
    </dependency>
</dependencies>

4.4 仅使用第三方库(不依赖 EasyFK 封装)

BOM 同样管控了大量第三方依赖版本,即使不使用 EasyFK 模块也可以直接引用:

Gradle:

gradle
dependencies {
    implementation platform('com.mcst:easyfk-dependencies:${easyfk.version}')

    implementation 'com.baomidou:mybatis-plus-spring-boot3-starter'
    implementation 'com.alibaba:druid-spring-boot-starter'
    implementation 'com.mysql:mysql-connector-j'
    implementation 'org.redisson:redisson'
    implementation 'cn.hutool:hutool-all'
}

Maven:

xml
<dependencies>
    <dependency>
        <groupId>com.baomidou</groupId>
        <artifactId>mybatis-plus-spring-boot3-starter</artifactId>
    </dependency>
    <dependency>
        <groupId>com.alibaba</groupId>
        <artifactId>druid-spring-boot-starter</artifactId>
    </dependency>
    <dependency>
        <groupId>com.mysql</groupId>
        <artifactId>mysql-connector-j</artifactId>
    </dependency>
    <dependency>
        <groupId>org.redisson</groupId>
        <artifactId>redisson</artifactId>
    </dependency>
    <dependency>
        <groupId>cn.hutool</groupId>
        <artifactId>hutool-all</artifactId>
    </dependency>
</dependencies>

5. 版本覆盖

如果下游项目需要使用与 BOM 不同的版本,可以显式声明版本号进行覆盖。

Gradle:

gradle
dependencies {
    implementation platform('com.mcst:easyfk-dependencies:${easyfk.version}')

    // 显式覆盖版本
    implementation 'cn.hutool:hutool-all:5.x.x'
}

Maven:

xml
<dependencies>
    <dependency>
        <groupId>cn.hutool</groupId>
        <artifactId>hutool-all</artifactId>
        <version>5.x.x</version>
    </dependency>
</dependencies>
注意
非必要不建议覆盖 BOM 版本,以保持团队依赖一致性。如确需覆盖,请验证兼容性。

6. 依赖分组速查

BOM 内部将依赖按领域进行了分组,以下列出各分组及其包含的主要依赖,便于按需选择:

分组包含的主要依赖
basefastjson2、caffeine、kryo、slf4j-api、jasypt、lombok、hutool、swagger-annotations
logginglog-log4j2、log-logback、logstash-logback-encoder
skywalkingskywalking-log4j2、skywalking-logback
databasedb-influx、db-redis、db-mongo、db-mysql、db-postgresql、influxdb-client、shardingsphere
datasourcedruid-starter、datasource-druid、mongo-driver
ormorm-flex、orm-hibernate、orm-mybatis、orm-sharding
mybatismybatis-plus-starter、mysql-connector、dynamic-datasource
cachecache-redis、cache-mult、cache-caffeine
locklock-redisson、lock-zk
mqmq-kafka、mq-rocket、mq-rabbit、mq-xxl、mq-common、rocketmq-starter
microserviceregistry-nacos、config-nacos、protect-sentinel、gateway-gateway、doc-micro
rpcrpc-cloud、rpc-dubbo、dubbo-starter、dubbo-registry-nacos、remote-cloud、remote-dubbo
transactiontransaction-seata
xxlxxl-cache、xxl-job、xxl-mq、job-xxl
toolstool-http、tool-excel、component-autoId
docdoc-knife4j、knife4j-starter
easyfkCoreeasyfk-authority、easyfk-core、easyfk-cache、easyfk-doc、easyfk-lock、easyfk-mq、easyfk-thread、easyfk-repository、easyfk-resource
easyfkServiceservice-api、service-base
easyfkWebweb-common、web-micro、web-prd、web-base、web-simple
mapstructmapstruct-plus-starter
wxJavawx-java-miniapp、wx-java-mp、wx-java-pay、wx-java-cp
clickhouseclickhouse-jdbc、httpclient5、httpcore5
websocketwebsocket-api、websocket-server
storagequeue-disruptor、storage-chronicle、chronicle-map、chronicle-queue

7. 常见问题

Q1:引入 BOM 后是否会把所有依赖都加到项目中?

不会。BOM 只声明版本约束,不引入实际依赖。只有在 dependencies 中显式声明的依赖才会被加入项目,BOM 仅负责提供版本号。

Q2:BOM 中已包含 Spring Boot / Cloud BOM,项目还需要单独引入吗?

不需要。easyfk-dependencies 内部已引入 spring-boot-dependenciesspring-cloud-dependenciesspring-cloud-alibaba-dependencies,下游项目引入本 BOM 即可获得这些框架的版本管控。

Q3:Gradle 中 platform 和 enforcedPlatform 有什么区别?

  • platform:声明版本建议,下游仍可通过显式声明或传递依赖覆盖版本。
  • enforcedPlatform:强制使用 BOM 中的版本,即使传递依赖带来了更高版本也会被降级。

Q4:Maven 项目中如何同时使用 Spring Boot parent 和本 BOM?

使用 Spring Boot 作为 parent 时,将本 BOM 放在 <dependencyManagement> 中以 import 方式引入即可。对于同一依赖,<dependencyManagement> 中先声明的优先生效,可根据需要调整 BOM 的声明顺序。

Q5:如何查看当前 BOM 管控的具体版本号?

  • Gradle 项目:执行 ./gradlew dependencies 查看解析后的完整依赖树及版本。
  • Maven 项目:执行 mvn dependency:treemvn help:effective-pom 查看实际生效的版本。

Q6:私服地址如何配置?

本 BOM 发布在公司私服中,需要在构建配置中添加私服仓库地址:

Gradlebuild.gradlesettings.gradle):

gradle
repositories {
    maven { url 'https://your-nexus-host/repository/maven-public/' }
}

Mavenpom.xmlsettings.xml):

xml
<repositories>
    <repository>
        <id>company-nexus</id>
        <url>https://your-nexus-host/repository/maven-public/</url>
    </repository>
</repositories>

easyfk-dependencies — 一个 BOM 坐标,统管所有依赖版本。

— END —