跳到主要内容
版本:5.0.1

Redis 后端

DeepSeek V3 中英对照 Redis Backend

Spring Cloud Config Server 支持将 Redis 作为配置属性的后端存储。您可以通过添加对 Spring Data Redis 的依赖来启用此功能。

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
</dependencies>

以下配置使用 Spring Data RedisTemplate 来访问 Redis。我们可以使用 spring.redis.* 属性来覆盖默认连接设置。

spring:
profiles:
active: redis
redis:
host: redis
port: 16379

属性应存储在哈希表中。哈希表的名称应与 spring.application.name 属性相同,或是 spring.application.name 与 spring.profiles.active[n] 的组合。

HMSET sample-app server.port "8100" sample.topic.name "test" test.property1 "property1"

运行上述命令后,哈希应包含以下键值对:

HGETALL sample-app
{
"server.port": "8100",
"sample.topic.name": "test",
"test.property1": "property1"
}
备注

当未指定配置文件时,将使用 default。