mirror of
https://gitee.com/dromara/sa-token.git
synced 2026-05-14 04:42:09 +08:00
docs: 添加 SpringBoot4 引入说明
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
|
||||
<!---------------------------- tabs:start ------------------------------>
|
||||
<!-------- tab:Maven 方式 -------->
|
||||
注:如果你使用的是 `SpringBoot 3.x`,只需要将 `sa-token-reactor-spring-boot-starter` 修改为 `sa-token-reactor-spring-boot3-starter` 即可。
|
||||
``` xml
|
||||
<!-- Sa-Token 权限认证(Reactor响应式集成), 在线文档:https://sa-token.cc -->
|
||||
<dependency>
|
||||
@@ -36,8 +35,10 @@
|
||||
<artifactId>commons-pool2</artifactId>
|
||||
</dependency>
|
||||
```
|
||||
- 如果你使用的 `SpringBoot 3.x`,请引入 `sa-token-reactor-spring-boot3-starter`。
|
||||
- 如果你使用的 `SpringBoot 4.x`,请引入 `sa-token-reactor-spring-boot4-starter`。
|
||||
|
||||
<!-------- tab:Gradle 方式 -------->
|
||||
注:如果你使用的是 `SpringBoot 3.x`,只需要将 `sa-token-reactor-spring-boot-starter` 修改为 `sa-token-reactor-spring-boot3-starter` 即可。
|
||||
``` gradle
|
||||
// Sa-Token 权限认证(Reactor响应式集成),在线文档:https://sa-token.cc
|
||||
implementation 'cn.dev33:sa-token-reactor-spring-boot-starter:${sa.top.version}'
|
||||
@@ -46,6 +47,8 @@ implementation 'cn.dev33:sa-token-reactor-spring-boot-starter:${sa.top.version}'
|
||||
implementation 'cn.dev33:sa-token-redis-jackson:${sa.top.version}'
|
||||
implementation 'org.apache.commons:commons-pool2'
|
||||
```
|
||||
- 如果你使用的 `SpringBoot 3.x`,请引入 `sa-token-reactor-spring-boot3-starter`。
|
||||
- 如果你使用的 `SpringBoot 4.x`,请引入 `sa-token-reactor-spring-boot4-starter`。
|
||||
<!---------------------------- tabs:end ------------------------------>
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
|
||||
<!---------------------------- tabs:start ---------------------------->
|
||||
<!-------- tab:Maven 方式 -------->
|
||||
注:如果你使用的是 `SpringBoot 3.x`,只需要将 `sa-token-spring-boot-starter` 修改为 `sa-token-spring-boot3-starter` 即可。
|
||||
``` xml
|
||||
<!-- Sa-Token 权限认证,在线文档:https://sa-token.cc -->
|
||||
<dependency>
|
||||
@@ -21,17 +20,20 @@
|
||||
<version>${sa.top.version}</version>
|
||||
</dependency>
|
||||
```
|
||||
- 如果你使用的 `SpringBoot 3.x`,请引入 `sa-token-spring-boot3-starter`。
|
||||
- 如果你使用的 `SpringBoot 4.x`,请引入 `sa-token-spring-boot4-starter`。
|
||||
|
||||
<!-------- tab:Gradle 方式 -------->
|
||||
注:如果你使用的是 `SpringBoot 3.x`,只需要将 `sa-token-spring-boot-starter` 修改为 `sa-token-spring-boot3-starter` 即可。
|
||||
``` gradle
|
||||
// Sa-Token 权限认证,在线文档:https://sa-token.cc
|
||||
implementation 'cn.dev33:sa-token-spring-boot-starter:${sa.top.version}'
|
||||
```
|
||||
- 如果你使用的 `SpringBoot 3.x`,请引入 `sa-token-spring-boot3-starter`。
|
||||
- 如果你使用的 `SpringBoot 4.x`,请引入 `sa-token-spring-boot4-starter`。
|
||||
<!---------------------------- tabs:end ---------------------------->
|
||||
|
||||
<!---------------------------- tabs:start ------------------------------>
|
||||
<!-------- tab:Maven 方式 -------->
|
||||
注:如果你使用的是 `SpringBoot 3.x`,只需要将 `sa-token-reactor-spring-boot-starter` 修改为 `sa-token-reactor-spring-boot3-starter` 即可。
|
||||
``` xml
|
||||
<!-- Sa-Token 权限认证(Reactor响应式集成),在线文档:https://sa-token.cc -->
|
||||
<dependency>
|
||||
@@ -40,12 +42,16 @@ implementation 'cn.dev33:sa-token-spring-boot-starter:${sa.top.version}'
|
||||
<version>${sa.top.version}</version>
|
||||
</dependency>
|
||||
```
|
||||
- 如果你使用的 `SpringBoot 3.x`,请引入 `sa-token-reactor-spring-boot3-starter`。
|
||||
- 如果你使用的 `SpringBoot 4.x`,请引入 `sa-token-reactor-spring-boot4-starter`。
|
||||
|
||||
<!-------- tab:Gradle 方式 -------->
|
||||
注:如果你使用的是 `SpringBoot 3.x`,只需要将 `sa-token-reactor-spring-boot-starter` 修改为 `sa-token-reactor-spring-boot3-starter` 即可。
|
||||
``` gradle
|
||||
// Sa-Token 权限认证(Reactor响应式集成),在线文档:https://sa-token.cc
|
||||
implementation 'cn.dev33:sa-token-reactor-spring-boot-starter:${sa.top.version}'
|
||||
```
|
||||
- 如果你使用的 `SpringBoot 3.x`,请引入 `sa-token-reactor-spring-boot3-starter`。
|
||||
- 如果你使用的 `SpringBoot 4.x`,请引入 `sa-token-reactor-spring-boot4-starter`。
|
||||
<!---------------------------- tabs:end ------------------------------>
|
||||
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ Sa-Token提供两种解决方案:
|
||||
在网关处引入的依赖为(此处以 SpringCloud Gateway 为例):
|
||||
<!---------------------------- tabs:start ------------------------------>
|
||||
<!-------- tab:Maven 方式 -------->
|
||||
注:如果你使用的是 `SpringBoot 3.x`,只需要将 `sa-token-reactor-spring-boot-starter` 修改为 `sa-token-reactor-spring-boot3-starter` 即可。
|
||||
``` xml
|
||||
<!-- Sa-Token 权限认证(Reactor响应式集成), 在线文档:https://sa-token.cc -->
|
||||
<dependency>
|
||||
@@ -48,8 +47,10 @@ Sa-Token提供两种解决方案:
|
||||
<artifactId>commons-pool2</artifactId>
|
||||
</dependency>
|
||||
```
|
||||
- 如果你使用的 `SpringBoot 3.x`,请引入 `sa-token-reactor-spring-boot3-starter`。
|
||||
- 如果你使用的 `SpringBoot 4.x`,请引入 `sa-token-reactor-spring-boot4-starter`。
|
||||
|
||||
<!-------- tab:Gradle 方式 -------->
|
||||
注:如果你使用的是 `SpringBoot 3.x`,只需要将 `sa-token-reactor-spring-boot-starter` 修改为 `sa-token-reactor-spring-boot3-starter` 即可。
|
||||
``` gradle
|
||||
// Sa-Token 权限认证(Reactor响应式集成),在线文档:https://sa-token.cc
|
||||
implementation 'cn.dev33:sa-token-reactor-spring-boot-starter:${sa.top.version}'
|
||||
@@ -58,12 +59,13 @@ implementation 'cn.dev33:sa-token-reactor-spring-boot-starter:${sa.top.version}'
|
||||
implementation 'cn.dev33:sa-token-redis-jackson:${sa.top.version}'
|
||||
implementation 'org.apache.commons:commons-pool2'
|
||||
```
|
||||
- 如果你使用的 `SpringBoot 3.x`,请引入 `sa-token-reactor-spring-boot3-starter`。
|
||||
- 如果你使用的 `SpringBoot 4.x`,请引入 `sa-token-reactor-spring-boot4-starter`。
|
||||
<!---------------------------- tabs:end ------------------------------>
|
||||
|
||||
在下游子服务引入的依赖为:
|
||||
<!---------------------------- tabs:start ------------------------------>
|
||||
<!-------- tab:Maven 方式 -------->
|
||||
注:如果你使用的是 `SpringBoot 3.x`,只需要将 `sa-token-spring-boot-starter` 修改为 `sa-token-spring-boot3-starter` 即可。
|
||||
``` xml
|
||||
<!-- Sa-Token 权限认证, 在线文档:https://sa-token.cc -->
|
||||
<dependency>
|
||||
@@ -83,8 +85,10 @@ implementation 'org.apache.commons:commons-pool2'
|
||||
<artifactId>commons-pool2</artifactId>
|
||||
</dependency>
|
||||
```
|
||||
- 如果你使用的 `SpringBoot 3.x`,请引入 `sa-token-spring-boot3-starter`。
|
||||
- 如果你使用的 `SpringBoot 4.x`,请引入 `sa-token-spring-boot4-starter`。
|
||||
|
||||
<!-------- tab:Gradle 方式 -------->
|
||||
注:如果你使用的是 `SpringBoot 3.x`,只需要将 `sa-token-spring-boot-starter` 修改为 `sa-token-spring-boot3-starter` 即可。
|
||||
``` gradle
|
||||
// Sa-Token 权限认证,在线文档:https://sa-token.cc
|
||||
implementation 'cn.dev33:sa-token-spring-boot-starter:${sa.top.version}'
|
||||
@@ -93,6 +97,8 @@ implementation 'cn.dev33:sa-token-spring-boot-starter:${sa.top.version}'
|
||||
implementation 'cn.dev33:sa-token-redis-jackson:${sa.top.version}'
|
||||
implementation 'org.apache.commons:commons-pool2'
|
||||
```
|
||||
- 如果你使用的 `SpringBoot 3.x`,请引入 `sa-token-spring-boot3-starter`。
|
||||
- 如果你使用的 `SpringBoot 4.x`,请引入 `sa-token-spring-boot4-starter`。
|
||||
<!---------------------------- tabs:end ------------------------------>
|
||||
|
||||
##### 2、网关处添加Same-Token
|
||||
|
||||
@@ -625,9 +625,10 @@ Sa-Token 的部分 API 只能在 Web 上下文中才能调用,例如:`StpUti
|
||||
在 sa-token-core 核心包中,Sa-Token 底层不能确认最终运行的 web 容器,所以抽象了 `SaTokenContext` 接口,对接不同容器时需要注入不同的实现,
|
||||
通常这个注入工作都是框架自动完成的,你只需要按照文档开始部分集成相应的依赖即可。例如:
|
||||
|
||||
- 你要在 Springboot2.x 中使用 Sa-Token,就引入:`sa-token-spring-boot-starter`。
|
||||
- 你要在 Springboot3.x 中使用 Sa-Token,就引入:`sa-token-spring-boot3-starter`。
|
||||
- 你要在基于 webflux 架构的网关中使用 Sa-Token,就引入:`sa-token-reactor-spring-boot-starter`。
|
||||
- 如果你使用的 `SpringBoot 2.x`,请引入 `sa-token-spring-boot-starter`。
|
||||
- 如果你使用的 `SpringBoot 3.x`,请引入 `sa-token-spring-boot3-starter`。
|
||||
- 如果你使用的 `SpringBoot 4.x`,请引入 `sa-token-spring-boot4-starter`。
|
||||
- 如果你在基于 WebFlux 架构的网关中使用 Sa-Token,请引入 `sa-token-reactor-spring-boot-starter`(3.x 用 `sa-token-reactor-spring-boot3-starter`,4.x 用 `sa-token-reactor-spring-boot4-starter`)。
|
||||
- 你要在 Solon 中使用 Sa-Token,就引入:`sa-token-solon-plugin`。
|
||||
- 等等等等……
|
||||
|
||||
@@ -642,7 +643,7 @@ Sa-Token 的部分 API 只能在 Web 上下文中才能调用,例如:`StpUti
|
||||
- 如果引入了 `spring-boot-starter-webflux` 就是WebFlux环境。
|
||||
- 什么?你说你两个都引入了?那你的项目能启动成功吗?
|
||||
4. 如果是 WebFlux 环境而且正确引入了依赖,依然报错,**请检查是否注册了 SaReactorFilter 全局过滤器,在 WebFlux 下这一步是必须的**,具体还是请参考上面的 [ 在WebFlux环境集成 ] 章节。
|
||||
5. 需要仔细注意,如果你使用的是 Springboot3.x 版本,就不要错误的引入 `sa-token-spring-boot-starter`,需要引入的是 `sa-token-spring-boot3-starter`,不然就会导致框架报错。
|
||||
5. 需要仔细注意,如果你使用的是 `SpringBoot 3.x` 或 `SpringBoot 4.x`,请分别引入 `sa-token-spring-boot3-starter` 或 `sa-token-spring-boot4-starter`,不要错误引入 `sa-token-spring-boot-starter`,不然会导致框架报错。
|
||||
6. 如果你的项目开启了全局懒加载(spring.main.lazy-initialization=true)后,能启动项目,但是访问接口报异常,请直接参考:[Q:开启了全局懒加载后,能启动项目,但是访问接口报未能获取有效的上下文处理器](/more/common-questions?id=q:开启了全局懒加载后,能启动项目,但是访问接口报未能获取有效的上下文处理器)
|
||||
7. 如果以上步骤排除无误后依然报错,请直接提 issue 或者加入QQ群求助。
|
||||
|
||||
|
||||
@@ -19,7 +19,8 @@
|
||||
<version>${sa.top.version}</version>
|
||||
</dependency>
|
||||
```
|
||||
注:如果你使用的 `SpringBoot 3.x`,只需要将 `sa-token-spring-boot-starter` 修改为 `sa-token-spring-boot3-starter` 即可。
|
||||
- 如果你使用的 `SpringBoot 3.x`,请引入 `sa-token-spring-boot3-starter`。
|
||||
- 如果你使用的 `SpringBoot 4.x`,请引入 `sa-token-spring-boot4-starter`。
|
||||
|
||||
<!------------- tab:WebFlux环境 (Reactor) ------------->
|
||||
注:如果你使用的框架基于 Reactor 模型构建(WebFlux、SpringCloud Gateway 等),请引入此包
|
||||
@@ -31,7 +32,8 @@
|
||||
<version>${sa.top.version}</version>
|
||||
</dependency>
|
||||
```
|
||||
注:如果你使用的 `SpringBoot 3.x`,只需要将 `sa-token-reactor-spring-boot-starter` 修改为 `sa-token-reactor-spring-boot3-starter` 即可。
|
||||
- 如果你使用的 `SpringBoot 3.x`,请引入 `sa-token-reactor-spring-boot3-starter`。
|
||||
- 如果你使用的 `SpringBoot 4.x`,请引入 `sa-token-reactor-spring-boot4-starter`。
|
||||
|
||||
<!------------- tab:Solon 集成 ------------->
|
||||
参考:[Solon官网](https://solon.noear.org/)
|
||||
@@ -121,11 +123,15 @@
|
||||
``` gradle
|
||||
implementation 'cn.dev33:sa-token-spring-boot-starter:${sa.top.version}'
|
||||
```
|
||||
- 如果你使用的 `SpringBoot 3.x`,请引入 `sa-token-spring-boot3-starter`。
|
||||
- 如果你使用的 `SpringBoot 4.x`,请引入 `sa-token-spring-boot4-starter`。
|
||||
|
||||
<!-- tab:WebFlux环境 (Reactor) -->
|
||||
``` gradle
|
||||
implementation 'cn.dev33:sa-token-reactor-spring-boot-starter:${sa.top.version}'
|
||||
```
|
||||
- 如果你使用的 `SpringBoot 3.x`,请引入 `sa-token-reactor-spring-boot3-starter`。
|
||||
- 如果你使用的 `SpringBoot 4.x`,请引入 `sa-token-reactor-spring-boot4-starter`。
|
||||
|
||||
<!-- tab:Solon 集成 -->
|
||||
``` gradle
|
||||
|
||||
@@ -15,9 +15,6 @@
|
||||
|
||||
<!---------------------------- tabs:start ---------------------------->
|
||||
<!-------- tab:Maven 方式 -------->
|
||||
|
||||
注:如果你使用的是 SpringBoot 3.x,只需要将 `sa-token-spring-boot-starter` 修改为 `sa-token-spring-boot3-starter` 即可。
|
||||
|
||||
``` xml
|
||||
<!-- Sa-Token 权限认证,在线文档:https://sa-token.cc -->
|
||||
<dependency>
|
||||
@@ -26,15 +23,16 @@
|
||||
<version>${sa.top.version}</version>
|
||||
</dependency>
|
||||
```
|
||||
- 如果你使用的 `SpringBoot 3.x`,请引入 `sa-token-spring-boot3-starter`。
|
||||
- 如果你使用的 `SpringBoot 4.x`,请引入 `sa-token-spring-boot4-starter`。
|
||||
|
||||
<!-------- tab:Gradle 方式 -------->
|
||||
|
||||
注:如果你使用的是 SpringBoot 3.x,只需要将 `sa-token-spring-boot-starter` 修改为 `sa-token-spring-boot3-starter` 即可。
|
||||
|
||||
``` gradle
|
||||
// Sa-Token 权限认证,在线文档:https://sa-token.cc
|
||||
implementation 'cn.dev33:sa-token-spring-boot-starter:${sa.top.version}'
|
||||
```
|
||||
- 如果你使用的 `SpringBoot 3.x`,请引入 `sa-token-spring-boot3-starter`。
|
||||
- 如果你使用的 `SpringBoot 4.x`,请引入 `sa-token-spring-boot4-starter`。
|
||||
<!---------------------------- tabs:end ---------------------------->
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
|
||||
<!---------------------------- tabs:start ------------------------------>
|
||||
<!-------- tab:Maven 方式 -------->
|
||||
注:如果你使用的是 `SpringBoot 3.x`,只需要将 `sa-token-reactor-spring-boot-starter` 修改为 `sa-token-reactor-spring-boot3-starter` 即可。
|
||||
``` xml
|
||||
<!-- Sa-Token 权限认证(Reactor响应式集成),在线文档:https://sa-token.cc -->
|
||||
<dependency>
|
||||
@@ -30,20 +29,24 @@
|
||||
<version>${sa.top.version}</version>
|
||||
</dependency>
|
||||
```
|
||||
- 如果你使用的 `SpringBoot 3.x`,请引入 `sa-token-reactor-spring-boot3-starter`。
|
||||
- 如果你使用的 `SpringBoot 4.x`,请引入 `sa-token-reactor-spring-boot4-starter`。
|
||||
|
||||
<!-------- tab:Gradle 方式 -------->
|
||||
注:如果你使用的是 `SpringBoot 3.x`,只需要将 `sa-token-reactor-spring-boot-starter` 修改为 `sa-token-reactor-spring-boot3-starter` 即可。
|
||||
``` gradle
|
||||
// Sa-Token 权限认证(Reactor响应式集成),在线文档:https://sa-token.cc
|
||||
implementation 'cn.dev33:sa-token-reactor-spring-boot-starter:${sa.top.version}'
|
||||
```
|
||||
- 如果你使用的 `SpringBoot 3.x`,请引入 `sa-token-reactor-spring-boot3-starter`。
|
||||
- 如果你使用的 `SpringBoot 4.x`,请引入 `sa-token-reactor-spring-boot4-starter`。
|
||||
|
||||
<!-------- tab:Gradle (Kotlin) 方式 -------->
|
||||
注:如果你使用的是 `SpringBoot 3.x`,只需要将 `sa-token-reactor-spring-boot-starter` 修改为 `sa-token-reactor-spring-boot3-starter` 即可。
|
||||
``` gradle
|
||||
// Sa-Token 权限认证(Reactor响应式集成),在线文档:https://sa-token.cc
|
||||
implementation("cn.dev33:sa-token-reactor-spring-boot-starter:${sa.top.version}")
|
||||
```
|
||||
- 如果你使用的 `SpringBoot 3.x`,请引入 `sa-token-reactor-spring-boot3-starter`。
|
||||
- 如果你使用的 `SpringBoot 4.x`,请引入 `sa-token-reactor-spring-boot4-starter`。
|
||||
<!---------------------------- tabs:end ------------------------------>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user