Skip to content

依赖模块 (dependencies)

简介

continew-starter-dependencies 是 ContiNew Starter 项目的依赖管理模块,提供了统一的第三方库版本管理,简化项目配置,避免依赖冲突,确保所有模块使用一致的依赖版本。

快速开始

引入依赖

在你的 Maven 项目的 pom.xml 文件中,添加以下依赖管理配置:

pom.xml
xml
<dependencyManagement>
    <dependencies>
        <!-- ContiNew Starter Dependencies -->
        <dependency>
            <groupId>top.continew.starter</groupId>
            <artifactId>continew-starter-dependencies</artifactId>
            <version>{latest-version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

使用依赖

引入依赖管理后,在项目中使用具体依赖时无需指定版本号:

pom.xml
xml
<dependencies>
    <!-- Web 模块 -->
    <dependency>
        <groupId>top.continew.starter</groupId>
        <artifactId>continew-starter-web</artifactId>
    </dependency>
    
    <!-- Redisson(不仅仅是一个 Redis Java 客户端) -->
    <dependency>
        <groupId>org.redisson</groupId>
        <artifactId>redisson-spring-boot-starter</artifactId>
    </dependency>
</dependencies>

依赖版本管理

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

<!-- Cache and Storage Versions -->
<redisson.version>3.52.0</redisson.version>
<jetcache.version>2.7.9</jetcache.version>

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

<!-- Database and ORM Versions -->
<mybatis-plus.version>3.5.17</mybatis-plus.version>
<mybatis-flex.version>1.11.8</mybatis-flex.version>
<dynamic-datasource.version>4.5.0</dynamic-datasource.version>
<p6spy.version>3.9.1</p6spy.version>

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

<!-- Messaging and Notification Versions -->
<sms4j.version>3.3.5</sms4j.version>
<paho-mqttv3.version>1.2.5</paho-mqttv3.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.3.0</fastexcel.version>
<poi.version>5.5.1</poi.version>

<!-- File Storage Versions -->
<x-file-storage.version>2.3.0</x-file-storage.version>
<aws-sdk-v1.version>1.12.797</aws-sdk-v1.version>
<aws-sdk.version>2.42.41</aws-sdk.version>
<aws-crt.version>0.48.3</aws-crt.version>
<thumbnails.version>0.4.21</thumbnails.version>

<!-- Validation and Response Processing Versions -->
<graceful-response.version>5.0.5-boot3</graceful-response.version>
<spel-validator.version>0.7.0</spel-validator.version>
<crane4j.version>2.10.0</crane4j.version>

<!-- API Documentation Versions -->
<nextdoc4j.version>1.4.1</nextdoc4j.version>
<springdoc.version>2.9.0</springdoc.version>
<swagger.version>2.2.54</swagger.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.6</zip4j.version>

<!-- HTTP Client and Utilities Versions -->
<okhttp.version>4.12.0</okhttp.version>
<ttl.version>2.14.5</ttl.version>
<ip2region.version>3.5.7</ip2region.version>
<hutool.version>5.8.47</hutool.version>
<snakeyaml.version>2.6</snakeyaml.version>
<nashorn.version>15.7</nashorn.version>

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

<!-- Maven Plugin Versions -->
<flatten.version>1.8.0</flatten.version>
<spotless.version>3.9.0</spotless.version>
<sonar.version>5.7.0.6970</sonar.version>

自定义依赖版本

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

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

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

如果你是通过 parent 方式引入的 ContiNew Starter:

pom.xml
xml
<parent>
    <groupId>top.continew.starter</groupId>
    <artifactId>continew-starter</artifactId>
    <version>{latest-version}</version>
</parent>

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

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

pom.xml
xml
<properties>
    <!-- 覆盖 Spring Boot 版本 -->
    <spring-boot.version>3.4.7</spring-boot.version>
</properties>

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

方式二:通过 dependencyManagement 管理

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