Thanks to visit codestin.com
Credit goes to github.com

Skip to content

mykumar/SpringCloudConfigExtensionRedis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SpringCloudConfigExtensionRedis

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.

Usage

Java configuration

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);
	}
}

Redis Config Server Properties Format

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

Test on Local Server

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"
      }
    }
  ]
}

Notes

About

Extending Spring Cloud Config Server With Redis As a Storage Solution

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages