Redis Backend

Spring Cloud Config Server supports Redis as a backend for configuration properties. You can enable this feature by adding a dependency to Spring Data Redis.
pom.xml

org.springframework.boot spring-boot-starter-data-redis

The following configuration uses Spring Data RedisTemplate to access a Redis. We can use spring.redis.* properties to override default connection settings.

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

The properties should be stored as fields in a hash. The name of hash should be the same as spring.application.name property or conjunction of spring.application.name and spring.profiles.active[n].

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

After executing the command visible above a hash should contain the following keys with values:

HGETALL sample-app
{
“server.port”: “8100”,
“sample.topic.name”: “test”,
“test.property1”: “property1”
}

When no profile is specified default will be used. 
发布了0 篇原创文章 · 获赞 135 · 访问量 5253

猜你喜欢

转载自blog.csdn.net/blog_programb/article/details/105191389