springcloud之configuration
springcloud之configuration
*Spring Cloud Config* is Spring's client/server approach for storing and serving distributed configurations across multiple applications and environments.
Configuration store - git version control
use config : Environment, PropertySource or @Value
Dependency
spring-cloud-config-server |
Config server
EnableConfigServer:
|
config git url
8888 = |
config file
file name : the value property ‘spring.application.name' of the client is used, followed by a dash and the active profile
$> git init |
config-client-${profile}.properties
- user.role=Developer
- user.role=User
query config
Path
/{application}/{profile}[/{label}] |
eg : curl http://root:s3cr3t@localhost:8888/config-client/development/master
SpringBootApplication |
bootstrap.properties
config-client = |
Encrytion/Decryption
The config server is per default enabled to encrypt property values in a symmetric or asymmetric way.
To use symmetric cryptography, you simply have to set the property ‘encrypt.key' in your application.properties to a secret of your choice. Alternatively you can pass-in the environment variable ENCRYPT_KEY.
For asymmetric cryptography, you can set ‘encrypt.key' to a PEM-encoded string value or configure a keystore to use.