Extending Spring Cloud Config Server With Redis As a Storage Solution for configuration properties, instead of the default Git repository which is supported by Spring Cloud Config.
import com.github.springccredis.spring.cloud.config.redis.EnableConfigServerRedis;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@EnableConfigServerRedis
@SpringBootApplication
public class CentralizedConfigServerApplication {
public static void main(String[] args) {
SpringApplication.run(CentralizedConfigServerApplication.class, args);
}
}
application-name:profile:label:property-name
For example, we have the following keys in Redis:
127.0.0.1:6379> set sccredis-app:default:master:url "http://sccredis-app.com"
OK
127.0.0.1:6379> set sccredis-app:h2-db:master:spring:datasource:name "sccredis-app-database"
OK
127.0.0.1:6379> set sccredis-app:h2-db:master:spring:datasource:password "sigmaSccredis"
OK
127.0.0.1:6379> set sccredis-app:h2-db:master:url "http://dev.sccredis-app.com"
OK
curl -X GET "http://localhost:8080/sccredis-app/h2-db"
which would return the following response:
{
"name": "sccredis-app",
"profiles": [
"h2-db"
],
"label": "master",
"version": null,
"propertySources": [
{
"name": "sccredis-app-h2-db",
"source": {
"spring.datasource.name": "sccredis-app-database",
"url": "http://dev.sccredis-app.com",
"spring.datasource.password": "sigmaSccredis"
}
},
{
"name": "sccredis-app",
"source": {
"url": "http://sccredis-app.com"
}
}
]
}
- Version support is not added, so responses from Redis Config Server will contain version as
null
- Plain Text file support is not added as in [Spring CLoud Config] (http://cloud.spring.io/spring-cloud-config/spring-cloud-config.html#_serving_plain_text)