Skip to content

调整 Starter 中依赖版本

最后更新: 10 天前
实践版本: v4.0.0

有一些同学在项目开发时,遇到了一些依赖版本的限制,想要升级或降级版本。但在框架里找了半天,也没有找到在哪里进行更改。

依赖版本管理机制

ContiNew Admin 框架的外部依赖版本主要由 ContiNew Starter 的 continew-starter-dependencies 模块统一锁定管理。(若你刚接触框架,对 ContiNew Admin 与 ContiNew Starter 的关系不太了解,可点击查看相关说明

以下是 ContiNew Starter v2.13.4 版本中锁定的依赖版本列表,不同版本的 Starter 可能会有差异,你可以直接查看对应版本的 continew-starter-dependencies 模块获取最新信息:

continew-starter-dependencies/pom.xml
xml
<!-- Core Framework Versions -->
<spring-boot.version>3.3.12</spring-boot.version>
<spring-cloud.version>2023.0.5</spring-cloud.version>

<!-- Cache and Storage Versions -->
<redisson.version>3.49.0</redisson.version>
<jetcache.version>2.7.8</jetcache.version>

<!-- Security and Authentication Versions -->
<sa-token.version>1.44.0</sa-token.version>
<just-auth.version>1.16.7</just-auth.version>

<!-- Database and ORM Versions -->
<mybatis-plus.version>3.5.12</mybatis-plus.version>
<mybatis-flex.version>1.10.9</mybatis-flex.version>
<dynamic-datasource.version>4.3.1</dynamic-datasource.version>
<p6spy.version>3.9.1</p6spy.version>

<!-- ID Generator and Job Scheduler Versions -->
<cosid.version>2.13.0</cosid.version>
<snail-job.version>1.5.0</snail-job.version>

<!-- Messaging and Notification Versions -->
<sms4j.version>3.3.5</sms4j.version>

<!-- Captcha Versions -->
<aj-captcha.version>1.4.0</aj-captcha.version>
<easy-captcha.version>1.6.2</easy-captcha.version>

<!-- Excel Processing Versions -->
<fastexcel.version>1.2.0</fastexcel.version>
<poi.version>5.4.1</poi.version>

<!-- File Storage Versions -->
<x-file-storage.version>2.2.1</x-file-storage.version>
<aws-s3-v1.version>1.12.783</aws-s3-v1.version>
<aws-sdk.version>2.31.63</aws-sdk.version>
<aws-crt.version>0.38.5</aws-crt.version>
<thumbnails.version>0.4.20</thumbnails.version>

<!-- Validation and Response Processing Versions -->
<graceful-response.version>5.0.5-boot3</graceful-response.version>
<spel-validator.version>0.5.2-beta</spel-validator.version>
<crane4j.version>2.9.0</crane4j.version>

<!-- API Documentation Versions -->
<knife4j.version>4.5.0</knife4j.version>

<!-- Tracing and Logging Versions -->
<tlog.version>1.5.2</tlog.version>

<!-- License and Compression Versions -->
<truelicense.version>1.33</truelicense.version>
<zip4j.version>2.11.5</zip4j.version>

<!-- HTTP Client and Utilities Versions -->
<okhttp.version>4.12.0</okhttp.version>
<ttl.version>2.14.5</ttl.version>
<ip2region.version>3.3.6</ip2region.version>
<hutool.version>5.8.38</hutool.version>
<snakeyaml.version>2.4</snakeyaml.version>
<nashorn.version>15.6</nashorn.version>

<!-- Security Vulnerability Fix Versions -->
<commons-beanutils.version>1.11.0</commons-beanutils.version>
<commons-io.version>2.17.0</commons-io.version>
<commons-compress.version>1.26.0</commons-compress.version>

<!-- Maven Plugin Versions -->
<flatten.version>1.7.0</flatten.version>
<spotless.version>2.44.3</spotless.version>
<sonar.version>3.11.0.3922</sonar.version>

关于修改依赖版本的建议

原则上,我们不建议直接修改 ContiNew Starter 中锁定的依赖版本。这是因为 Starter 的核心作用就是集中管理依赖版本,确保各组件之间的兼容性,避免版本冲突。自行调整版本可能会导致不可预见的兼容性问题。

但如果你有特殊需求或无法等待 Starter 版本更新,可以通过以下方法调整依赖版本:

方式一:通过 Maven 继承特性修改(推荐)

如果你是通过 parent 方式引入的 ContiNew Starter(ContiNew Admin 默认采用此方式):

continew-admin/pom.xml
xml
<!--
    下方 parent 为 ContiNew Starter(Continue New Starter)。
    ContiNew Starter 基于"约定优于配置"的理念,
    再次精简常规配置,提供一个更为完整的配置解决方案,帮助开发人员更加快速的集成常用第三方库或工具到 Spring Boot Web 应用程序中。
    ContiNew Starter 包含了一系列经过企业实践优化的依赖包(如 MyBatis-Plus、SaToken),
    可轻松集成到应用中,为开发人员减少手动引入依赖及配置的麻烦,为 Spring Boot Web 项目的灵活快速构建提供支持。
-->
<parent>
    <groupId>top.continew.starter</groupId>
    <artifactId>continew-starter</artifactId>
    <version>最新版本</version>
</parent>

你可以利用 Maven 的继承特性,在项目的 pom.xml 文件中通过覆盖 properties 中的依赖版本变量来调整版本。

例如:要将 Spring Boot 版本调整为 3.4.7,只需在 pom.xml 中添加:

continew-admin/pom.xml
xml
<properties>
    <spring-boot.version>3.4.7</spring-boot.version>
</properties>

注意:你需要确保覆盖的变量名称与 ContiNew Starter continew-starter-dependencies 模块中定义的完全一致。

方式二:通过 dependencyManagement 管理

基于 Maven 的依赖解析原则(路径最近者优先、第一声明者优先),你可以在项目的 pom.xml 文件中通过 dependencyManagement 标签直接管理依赖版本。这种方式可以更精细地控制特定依赖的版本。