dependencies.xml 2.28 KB
<?xml version="1.0" encoding="UTF-8"?>
<!--
    限流熔断(Sentinel 1.8.10)的 Maven 依赖片段,不是 Maven 工程,不参与项目构建。

    使用时,将下面的 <dependency> 复制到【包含 @SentinelResource 等 Sentinel 代码】的模块的 pom.xml 的 <dependencies> 中:
      - 示例代码在 yudao-module-infra 中,添加到 yudao-module-infra/pom.xml;
        yudao-server 已经依赖 yudao-module-infra,会传递获得这些依赖。只加在 yudao-server/pom.xml 时,yudao-module-infra 编译失败

    三个分支(master、master-jdk17、master-jdk25)复制同样的内容,不需要按分支选择。
    单体项目没有 Spring Cloud Alibaba 的 BOM,所以显式指定 Sentinel 的版本;不要为了 Sentinel 引入 Spring Cloud、Spring Cloud Alibaba 的 BOM 或 starter。
    三个依赖的版本必须一致。
-->
<dependencies>

    <!-- ========== 1. Sentinel 核心 + @SentinelResource 注解切面:必须 ========== -->
    <!--
        sentinel-annotation-aspectj 会传递依赖 aspectjweaver,版本由项目的 Spring Boot BOM 统一管理,不会改变项目原有的版本。
        示例不使用 sentinel-spring-webmvc-adapter 等 Web 适配模块,不区分 javax、jakarta。
    -->
    <dependency>
        <groupId>com.alibaba.csp</groupId>
        <artifactId>sentinel-core</artifactId>
        <version>1.8.10</version>
    </dependency>
    <dependency>
        <groupId>com.alibaba.csp</groupId>
        <artifactId>sentinel-annotation-aspectj</artifactId>
        <version>1.8.10</version>
    </dependency>

    <!-- ========== 2. 与 Sentinel Dashboard 通信:可选,不使用 Dashboard 时不需要添加 ========== -->
    <!--
        添加后,应用会在本机开启 Sentinel 的命令端口(默认 8719,被占用时自动递增),Dashboard 通过它查询监控数据、推送规则。
        该端口没有鉴权,只能在内网访问,不要对公网开放。
        它会传递依赖 fastjson(1.2.83_noneautotype,Sentinel 内部的命令处理使用),不会替换项目接口使用的 Jackson。
    -->
    <dependency>
        <groupId>com.alibaba.csp</groupId>
        <artifactId>sentinel-transport-simple-http</artifactId>
        <version>1.8.10</version>
    </dependency>

</dependencies>