sa-token/sa-token-plugin/sa-token-dao-redisx/README.md

34 lines
631 B
Markdown
Raw Normal View History

2022-05-10 13:47:49 +08:00
### 使用示例
#### 1.配置
```yaml
sa-token-dao: #名字可以随意取
redis:
server: "localhost:6379"
password: 123456
db: 1
# serializer: "org.noear.redisx.utils.SerializerJson" #指定自定义序列化实现(默认为 SerializerDefault
2022-05-10 13:47:49 +08:00
```
#### 2.代码
**注入风格**
```java
@Configuration
public class Config {
@Bean
public SaTokenDao saTokenDaoInit(@Inject("${sa-token-dao.redis}") SaTokenDaoOfRedis saTokenDao) {
return saTokenDao;
}
}
```
**手动风格**
```java
SaTokenDaoOfRedis saTokenDao = new SaTokenDaoOfRedis(props);
SaManager.setSaTokenDao(saTokenDao);
```