spring: ++ server: + git: + uri: https://github.com/spring-cloud-samples/config-repospring: cloud: config: - server: - git: - uri: https://github.com/spring-cloud-samples/config-repo
From 1e284961d503731504ee5dbc53fa26fcca44db1f Mon Sep 17 00:00:00 2001
From: Dave Syer
Java 6 JCE Link http://www.oracle.com/technetwork/java/javase/downloads/jce-6-download-429243.html
+Java 7 JCE Link http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html
+Java 8 JCE Link http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html
+Extract files into JDK/jre/lib/security folder (whichever version of JRE/JDK x64/x86 you are using).
|
+ Note
+ |
++Spring Cloud is released under the non-restrictive Apache 2.0 license. If you would like to contribute to this section of the documentation or if you find an error, please find the source code and issue trackers in the project at {githubmaster}/docs/src/main/asciidoc[github]. + | +
include::jce.adoc
+If you are getting an exception due to "Illegal key size" and you are using Sun’s JDK, you need to install the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files. See the following links for more information:
+Extract files into JDK/jre/lib/security folder (whichever version of JRE/JDK x64/x86 you are using).
LoadBalancerClient bean
The URI needs to use a virtual host name (ie. service name, not a host name).
The Ribbon client is used to create a full physical address. See
-{github-code}/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/ribbon/RibbonAutoConfiguration.java[RibbonAutoConfiguration]
+RibbonAutoConfiguration
for details of how the RestTemplate is set up.
The default strategy for locating property sources is to clone a git
-repository (at "spring.cloud.config.server.git.uri") and use it to
+repository (at spring.cloud.config.server.git.uri) and use it to
initialize a mini SpringApplication. The mini-application’s
Environment is used to enumerate property sources and publish them
via a JSON endpoint.
where the "application" is injected as the "spring.config.name" in the +
where the "application" is injected as the spring.config.name in the
SpringApplication (i.e. what is normally "application" in a regular
Spring Boot app), "profile" is an active profile (or comma-separated
list of properties), and "label" is an optional git label (defaults to
@@ -1146,12 +1171,12 @@ from a git repository (which must be provided):
spring: ++ server: + git: + uri: https://github.com/spring-cloud-samples/config-repospring: cloud: config: - server: - git: - uri: https://github.com/spring-cloud-samples/config-repo
@Configuration -@EnableAutoConfiguration +@SpringBootApplication @RestController public class Application { @@ -1323,6 +1347,19 @@ spring.cloud.config.server.git.uri: file://${user.home}/config-repowhere
${user.home}/config-repois a git repository containing YAML and properties files.
|
+ Note
+ |
+
+in Windows you need an extra "/" in the file URL if it is
+absolute with a drive prefix, e.g. file:///${user.home}/config-repo.
+ |
+
|
+ Note
+ |
+
+Remember to use the file: prefix for file resources (the
+default without a prefix is usually the classpath). Just as with any
+Spring Boot configuration you can embed ${}-style environment
+placeholders, but remember that absolute paths in Windows require an
+extra "/", e.g. file:///${user.home}/config-repo
+ |
+
Normal, Spring environment placeholders with "${}" can be escaped
(and resolved on the client) by using backslash ("\") to escape the
-"$", e.g. \${app.foo:bar} resolves to "bar" unless the app provides
-its own "app.foo". Note that in YAML you don’t need to escape the
-backslash itself, but in properties files you do, when you configure
-the overrides on the server.
+"$" or the "{", e.g. \${app.foo:bar} resolves to "bar" unless the
+app provides its own "app.foo". Note that in YAML you don’t need to
+escape the backslash itself, but in properties files you do, when you
+configure the overrides on the server.
|
spring: ++ profiles: developmentspring: cloud: config: server: @@ -1820,7 +1873,7 @@ along with custom profiles and custom labels, e.g. label: mylabel myservice-dev: name: myservice - profiles: development
If the remote property sources contain encryted content +
If the remote property sources contain encrypted content
(values starting with {cipher}) they will be decrypted before
sending to clients over HTTP. The main advantage of this set up is
that the property values don’t have to be in plain text when they are
@@ -1880,10 +1933,10 @@ instance:
spring: ++ password: '{cipher}FKSAJDFGYOS8F7GLHAKERGFHLSAJ'spring: datasource: username: dbuser - password: '{cipher}FKSAJDFGYOS8F7GLHAKERGFHLSAJ'
Take the encrypted value and add the {cipher} prefix before you put
it in the YAML or properties file, and before you commit and push it
-to a remote, potentially insecure store. The /encrypt and /decrypt
-endpoints also both accept paths of the form /*/{name}/{profiles}
-which can be used to control cryptography per application (name)
-and profile when clients call into the main Environment resource.
The /encrypt and /decrypt endpoints also both accept paths of the
+form /*/{name}/{profiles} which can be used to control cryptography
+per application (name) and profile when clients call into the main
+Environment resource.
application.yml for the Config Server:
encrypt: ++ secret: changemeencrypt: keyStore: location: classpath:/server.jks password: letmein alias: mytestkey - secret: changeme
foo:
- bar: `{cipher}{key:testkey}...`
+foo:
+ bar: `{cipher}{key:testkey}...`
logback.xml).
The Config Server runs best as a standalone application, but if you
need to you can embed it in another application. Just use the
-@EnableConfigServer annotation and (optionally) set
-spring.cloud.config.server.prefix to a path prefix, e.g. "/config",
-to serve the resources under a prefix. The prefix should start but not
-end with a "/". It is applied to the @RequestMappings in the Config
-Server (i.e. underneath the Spring Boot prefixes server.servletPath
-and server.contextPath). Another optional property that can be
+@EnableConfigServer annotation. An optional property that can be
useful in this case is spring.cloud.config.server.bootstrap which is
a flag to indicate that the server should configure itself from its
own remote repository. The flag is off by default because it can delay
startup, but when embedded in another application it makes sense to
initialize the same way as any other application.
|
+ Note
+ |
+
+It should be obvious, but remember that if you use the bootstrap
+flag the config server will need to have its name and repository URI
+configured in bootstrap.yml.
+ |
+
To change the location of the server endpoints you can (optionally)
+set spring.cloud.config.server.prefix, e.g. "/config", to serve the
+resources under a prefix. The prefix should start but not end with a
+"/". It is applied to the @RequestMappings in the Config Server
+(i.e. underneath the Spring Boot prefixes server.servletPath and
+server.contextPath).
If you want to read the configuration for an application directly from
+the backend repository (instead of from the config server) that’s
+basically an embedded config server with no endpoints. You can switch
+off the endpoints entirely if you don’t use the @EnableConfigServer
+annotation (just set spring.cloud.config.server.bootstrap=true).
spring.cloud.config.failFast=true, and then you need to add
spring-retry and spring-boot-starter-aop to your classpath. The default
behaviour is to retry 6 times with an initial backoff interval of 1000ms and an
exponential multiplier of 1.1 for subsequent backoffs. You can configure these
-properties (and others) using spring.config.retry.* configuration properties.
+properties (and others) using spring.cloud.config.retry.* configuration properties.