大网数据广告活动
数据库部署与 SQL 参考

物料清单 (BOM)

· 52CE 我爱测

物料清单 (Bill of Materials, BOM) 是 Maven 的标准功能,提供集中化的依赖版本管理。ShardingSphere BOM 确保所有模块使用兼容的版本,消除版本冲突并简化依赖管理。

物料清单 (Bill of Materials, BOM) 是 Maven 的标准功能,提供集中化的依赖版本管理。ShardingSphere BOM 确保所有模块使用兼容的版本,消除版本冲突并简化依赖管理。

什么是 ShardingSphere BOM?

ShardingSphere BOM (shardingsphere-bom) 是一个包含所有 ShardingSphere 模块版本信息的 POM 文件。通过在项目中导入 BOM,您不再需要为单个 ShardingSphere 依赖指定版本。

使用 BOM 的优势

  • 版本一致性:确保所有 ShardingSphere 模块使用兼容版本
  • 简化依赖管理:无需为单个模块指定版本
  • 轻松升级:只需更改 BOM 版本即可升级所有 ShardingSphere 依赖
  • 减少 POM 体积:更清晰、更易读的依赖声明
  • 冲突预防:避免传递依赖之间的版本冲突

Maven 配置

要在 Maven 项目中使用 ShardingSphere BOM,请在您的 pom.xml 中添加以下配置:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.apache.shardingsphere</groupId>
            <artifactId>shardingsphere-bom</artifactId>
            <version>${shardingsphere.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

导入 BOM 后,您可以声明 ShardingSphere 依赖而无需指定版本:

<dependencies>
    
    <dependency>
        <groupId>org.apache.shardingsphere</groupId>
        <artifactId>shardingsphere-jdbc</artifactId>
    </dependency>

    
    <dependency>
        <groupId>org.apache.shardingsphere</groupId>
        <artifactId>shardingsphere-parser-sql-engine-mysql</artifactId>
    </dependency>

    
    <dependency>
        <groupId>org.apache.shardingsphere</groupId>
        <artifactId>shardingsphere-infra-data-source-pool-hikari</artifactId>
    </dependency>
</dependencies>

Gradle 支持

对于 Gradle 用户,您可以通过 dependencyManagement 插件使用 BOM:

plugins {
    id 'java'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
}

dependencyManagement {
    imports {
        mavenBom "org.apache.shardingsphere:shardingsphere-bom:${shardingsphereVersion}"
    }
}

dependencies {
    implementation 'org.apache.shardingsphere:shardingsphere-jdbc'
    implementation 'org.apache.shardingsphere:shardingsphere-parser-sql-engine-mysql'
}

本文来自 Apache ShardingSphere 文档贡献者,按 Apache 2.0 整理版式与相对链接,保留正文与代码。图示请参阅原文。作者与贡献记录。

资料来源与适用范围

资料来源
Apache ShardingSphere 文档贡献者
适用范围
master 文档快照(2026-11-16)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-16
授权说明
Apache 2.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。