依赖模块 (dependencies)
简介
continew-starter-dependencies
是 ContiNew Starter 项目的依赖管理模块,提供了统一的第三方库版本管理,简化项目配置,避免依赖冲突,确保所有模块使用一致的依赖版本。
快速开始
引入依赖
在你的 Maven 项目的 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>
使用依赖
引入依赖管理后,在项目中使用具体依赖时无需指定版本号:
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>
依赖版本管理
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:
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
中添加:
xml
<properties>
<!-- 覆盖 Spring Boot 版本 -->
<spring-boot.version>3.4.7</spring-boot.version>
</properties>
注意:你需要确保覆盖的属性名称与 continew-starter-dependencies
模块中定义的完全一致。
方式二:通过 dependencyManagement 管理
基于 Maven 的依赖解析原则(路径最近者优先、第一声明者优先),你可以在项目的 pom.xml
文件中通过 dependencyManagement
标签直接管理依赖版本。