2022-05-10 13:47:49 +08:00
|
|
|
|
|
2023-05-14 01:31:10 +08:00
|
|
|
|
sa-token-redisx 是中立的扩展。可任何应用开发框架下使用(springboot, solon, jfinal 等..)
|
2023-01-14 09:33:25 +08:00
|
|
|
|
|
2022-05-10 13:47:49 +08:00
|
|
|
|
### 使用示例
|
|
|
|
|
|
|
|
|
|
#### 1.配置
|
|
|
|
|
|
|
|
|
|
```yaml
|
2023-05-14 01:31:10 +08:00
|
|
|
|
sa-token: #名字可以随意取
|
2022-05-10 13:47:49 +08:00
|
|
|
|
redis:
|
|
|
|
|
server: "localhost:6379"
|
|
|
|
|
password: 123456
|
|
|
|
|
db: 1
|
2023-01-14 09:30:03 +08:00
|
|
|
|
# serializer: "org.noear.redisx.utils.SerializerJson" #指定自定义序列化实现(默认为 SerializerDefault)
|
2022-05-10 13:47:49 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### 2.代码
|
|
|
|
|
|
|
|
|
|
**注入风格**
|
|
|
|
|
|
|
|
|
|
```java
|
|
|
|
|
@Configuration
|
|
|
|
|
public class Config {
|
|
|
|
|
@Bean
|
2023-05-14 01:31:10 +08:00
|
|
|
|
public SaTokenDao saTokenDaoInit(@Inject("${sa-token.redis}") SaTokenDaoOfRedis saTokenDao) {
|
2022-05-10 13:47:49 +08:00
|
|
|
|
return saTokenDao;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
**手动风格**
|
|
|
|
|
|
|
|
|
|
```java
|
|
|
|
|
SaTokenDaoOfRedis saTokenDao = new SaTokenDaoOfRedis(props);
|
|
|
|
|
SaManager.setSaTokenDao(saTokenDao);
|
|
|
|
|
```
|