Sync docs from 2.1.x to gh-pages
This commit is contained in:
@@ -7,5 +7,5 @@ If you add a dependency on the <code class="literal">spring-cloud-config-monitor
|
||||
The change detection can be strategized.
|
||||
However, by default, it looks for changes in files that match the application name (for example, <code class="literal">foo.properties</code> is targeted at the <code class="literal">foo</code> application, while <code class="literal">application.properties</code> is targeted at all applications).
|
||||
The strategy to use when you want to override the behavior is <code class="literal">PropertyPathNotificationExtractor</code>, which accepts the request headers and body as parameters and returns a list of file paths that changed.</p><p>The default configuration works out of the box with Github, Gitlab, Gitea, Gitee, Gogs or Bitbucket.
|
||||
In addition to the JSON notifications from Github, Gitlab, Gitee, or Bitbucket, you can trigger a change notification by POSTing to <code class="literal">/monitor</code> with form-encoded body parameters in the pattern of <code class="literal">path={name}</code>.
|
||||
Doing so broadcasts to applications matching the <code class="literal">{name}</code> pattern (which can contain wildcards).</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>The <code class="literal">RefreshRemoteApplicationEvent</code> is transmitted only if the <code class="literal">spring-cloud-bus</code> is activated in both the Config Server and in the client application.</p></td></tr></table></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>The default configuration also detects filesystem changes in local git repositories. In that case, the webhook is not used. However, as soon as you edit a config file, a refresh is broadcast.</p></td></tr></table></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__embedding_the_config_server.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="multi__spring_cloud_config_client.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">5. Embedding the Config Server </td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud-config.html">Home</a></td><td width="40%" align="right" valign="top"> 7. Spring Cloud Config Client</td></tr></table></div></body></html>
|
||||
In addition to the JSON notifications from Github, Gitlab, Gitee, or Bitbucket, you can trigger a change notification by POSTing to <code class="literal">/monitor</code> with form-encoded body parameters in the pattern of <code class="literal">path={application}</code>.
|
||||
Doing so broadcasts to applications matching the <code class="literal">{application}</code> pattern (which can contain wildcards).</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>The <code class="literal">RefreshRemoteApplicationEvent</code> is transmitted only if the <code class="literal">spring-cloud-bus</code> is activated in both the Config Server and in the client application.</p></td></tr></table></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>The default configuration also detects filesystem changes in local git repositories. In that case, the webhook is not used. However, as soon as you edit a config file, a refresh is broadcast.</p></td></tr></table></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__embedding_the_config_server.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="multi__spring_cloud_config_client.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">5. Embedding the Config Server </td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud-config.html">Home</a></td><td width="40%" align="right" valign="top"> 7. Spring Cloud Config Client</td></tr></table></div></body></html>
|
||||
@@ -1,7 +1,7 @@
|
||||
<html><head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>4. Serving Plain Text</title><link rel="stylesheet" type="text/css" href="css/manual-multipage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.79.1"><link rel="home" href="multi_spring-cloud-config.html" title="Spring Cloud Config"><link rel="up" href="multi_spring-cloud-config.html" title="Spring Cloud Config"><link rel="prev" href="multi__serving_alternative_formats.html" title="3. Serving Alternative Formats"><link rel="next" href="multi__embedding_the_config_server.html" title="5. Embedding the Config Server"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">4. Serving Plain Text</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__serving_alternative_formats.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="multi__embedding_the_config_server.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="_serving_plain_text" href="#_serving_plain_text"></a>4. Serving Plain Text</h1></div></div></div><p>Instead of using the <code class="literal">Environment</code> abstraction (or one of the alternative representations of it in YAML or properties format), your applications might need generic plain-text configuration files that are tailored to their environment.
|
||||
The Config Server provides these through an additional endpoint at <code class="literal">/{name}/{profile}/{label}/{path}</code>, where <code class="literal">name</code>, <code class="literal">profile</code>, and <code class="literal">label</code> have the same meaning as the regular environment endpoint, but <code class="literal">path</code> is a file name (such as <code class="literal">log.xml</code>).
|
||||
The Config Server provides these through an additional endpoint at <code class="literal">/{application}/{profile}/{label}/{path}</code>, where <code class="literal">application</code>, <code class="literal">profile</code>, and <code class="literal">label</code> have the same meaning as the regular environment endpoint, but <code class="literal">path</code> is a path to a file name (such as <code class="literal">log.xml</code>).
|
||||
The source files for this endpoint are located in the same way as for the environment endpoints.
|
||||
The same search path is used for properties and YAML files.
|
||||
However, instead of aggregating all matching resources, only the first one to match is returned.</p><p>After a resource is located, placeholders in the normal format (<code class="literal">${…​}</code>) are resolved by using the effective <code class="literal">Environment</code> for the supplied application name, profile, and label.
|
||||
|
||||
@@ -26,7 +26,7 @@ First, you need to set <code class="literal">spring.cloud.config.fail-fast=true<
|
||||
Then you need to add <code class="literal">spring-retry</code> and <code class="literal">spring-boot-starter-aop</code> to your classpath.
|
||||
The default behavior is to retry six 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) by setting the <code class="literal">spring.cloud.config.retry.*</code> configuration properties.</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>To take full control of the retry behavior, add a <code class="literal">@Bean</code> of type <code class="literal">RetryOperationsInterceptor</code> with an ID of <code class="literal">configServerRetryInterceptor</code>.
|
||||
Spring Retry has a <code class="literal">RetryInterceptorBuilder</code> that supports creating one.</p></td></tr></table></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_locating_remote_configuration_resources" href="#_locating_remote_configuration_resources"></a>7.5 Locating Remote Configuration Resources</h2></div></div></div><p>The Config Service serves property sources from <code class="literal">/{name}/{profile}/{label}</code>, where the default bindings in the client app are as follows:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">"name" = <code class="literal">${spring.application.name}</code></li><li class="listitem">"profile" = <code class="literal">${spring.profiles.active}</code> (actually <code class="literal">Environment.getActiveProfiles()</code>)</li><li class="listitem">"label" = "master"</li></ul></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>When setting the property <code class="literal">${spring.application.name}</code> do not prefix your app name with the reserved word <code class="literal">application-</code> to prevent issues resolving the correct property source.</p></td></tr></table></div><p>You can override all of them by setting <code class="literal">spring.cloud.config.*</code> (where <code class="literal">*</code> is <code class="literal">name</code>, <code class="literal">profile</code> or <code class="literal">label</code>).
|
||||
Spring Retry has a <code class="literal">RetryInterceptorBuilder</code> that supports creating one.</p></td></tr></table></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_locating_remote_configuration_resources" href="#_locating_remote_configuration_resources"></a>7.5 Locating Remote Configuration Resources</h2></div></div></div><p>The Config Service serves property sources from <code class="literal">/{application}/{profile}/{label}</code>, where the default bindings in the client app are as follows:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">"name" = <code class="literal">${spring.application.name}</code></li><li class="listitem">"profile" = <code class="literal">${spring.profiles.active}</code> (actually <code class="literal">Environment.getActiveProfiles()</code>)</li><li class="listitem">"label" = "master"</li></ul></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>When setting the property <code class="literal">${spring.application.name}</code> do not prefix your app name with the reserved word <code class="literal">application-</code> to prevent issues resolving the correct property source.</p></td></tr></table></div><p>You can override all of them by setting <code class="literal">spring.cloud.config.*</code> (where <code class="literal">*</code> is <code class="literal">name</code>, <code class="literal">profile</code> or <code class="literal">label</code>).
|
||||
The <code class="literal">label</code> is useful for rolling back to previous versions of configuration.
|
||||
With the default Config Server implementation, it can be a git label, branch name, or commit ID.
|
||||
Label can also be provided as a comma-separated list.
|
||||
|
||||
@@ -451,7 +451,7 @@ If you edit a remote config file, you can use the Config Server to encrypt value
|
||||
682bc583f4641835fa2db009355293665d2647dade3375c0ee201de2a49f7bda</pre><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>If the value you encrypt has characters in it that need to be URL encoded, you should use the <code class="literal">--data-urlencode</code> option to <code class="literal">curl</code> to make sure they are encoded properly.</p></td></tr></table></div><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>Be sure not to include any of the curl command statistics in the encrypted value.
|
||||
Outputting the value to a file can help avoid this problem.</p></td></tr></table></div><p>The inverse operation is also available through <code class="literal">/decrypt</code> (provided the server is
|
||||
configured with a symmetric key or a full key pair), as shown in the following example:</p><pre class="screen">$ curl localhost:8888/decrypt -d 682bc583f4641835fa2db009355293665d2647dade3375c0ee201de2a49f7bda
|
||||
mysecret</pre><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>If you testing with curl, then use <code class="literal">--data-urlencode</code> (instead of <code class="literal">-d</code>) or set an explicit <code class="literal">Content-Type: text/plain</code> to make sure curl encodes the data correctly when there are special characters ('+' is particularly tricky).</p></td></tr></table></div><p>Take the encrypted value and add the <code class="literal">{cipher}</code> prefix before you put it in the YAML or properties file and before you commit and push it to a remote (potentially insecure) store.</p><p>The <code class="literal">/encrypt</code> and <code class="literal">/decrypt</code> endpoints also both accept paths in the form of <code class="literal">/*/{name}/{profiles}</code>, which can be used to control cryptography on a per-application (name) and per-profile basis when clients call into the main environment resource.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>To control the cryptography in this granular way, you must also provide a <code class="literal">@Bean</code> of type <code class="literal">TextEncryptorLocator</code> that creates a different encryptor per name and profiles.
|
||||
mysecret</pre><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>If you testing with curl, then use <code class="literal">--data-urlencode</code> (instead of <code class="literal">-d</code>) or set an explicit <code class="literal">Content-Type: text/plain</code> to make sure curl encodes the data correctly when there are special characters ('+' is particularly tricky).</p></td></tr></table></div><p>Take the encrypted value and add the <code class="literal">{cipher}</code> prefix before you put it in the YAML or properties file and before you commit and push it to a remote (potentially insecure) store.</p><p>The <code class="literal">/encrypt</code> and <code class="literal">/decrypt</code> endpoints also both accept paths in the form of <code class="literal">/*/{application}/{profiles}</code>, which can be used to control cryptography on a per-application (name) and per-profile basis when clients call into the main environment resource.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>To control the cryptography in this granular way, you must also provide a <code class="literal">@Bean</code> of type <code class="literal">TextEncryptorLocator</code> that creates a different encryptor per name and profiles.
|
||||
The one that is provided by default does not do so (all encryptions use the same key).</p></td></tr></table></div><p>The <code class="literal">spring</code> command line client (with Spring Cloud CLI extensions
|
||||
installed) can also be used to encrypt and decrypt, as shown in the following example:</p><pre class="screen">$ spring encrypt mysecret --key foo
|
||||
682bc583f4641835fa2db009355293665d2647dade3375c0ee201de2a49f7bda
|
||||
|
||||
@@ -535,7 +535,7 @@ If you edit a remote config file, you can use the Config Server to encrypt value
|
||||
682bc583f4641835fa2db009355293665d2647dade3375c0ee201de2a49f7bda</pre><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>If the value you encrypt has characters in it that need to be URL encoded, you should use the <code class="literal">--data-urlencode</code> option to <code class="literal">curl</code> to make sure they are encoded properly.</p></td></tr></table></div><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>Be sure not to include any of the curl command statistics in the encrypted value.
|
||||
Outputting the value to a file can help avoid this problem.</p></td></tr></table></div><p>The inverse operation is also available through <code class="literal">/decrypt</code> (provided the server is
|
||||
configured with a symmetric key or a full key pair), as shown in the following example:</p><pre class="screen">$ curl localhost:8888/decrypt -d 682bc583f4641835fa2db009355293665d2647dade3375c0ee201de2a49f7bda
|
||||
mysecret</pre><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>If you testing with curl, then use <code class="literal">--data-urlencode</code> (instead of <code class="literal">-d</code>) or set an explicit <code class="literal">Content-Type: text/plain</code> to make sure curl encodes the data correctly when there are special characters ('+' is particularly tricky).</p></td></tr></table></div><p>Take the encrypted value and add the <code class="literal">{cipher}</code> prefix before you put it in the YAML or properties file and before you commit and push it to a remote (potentially insecure) store.</p><p>The <code class="literal">/encrypt</code> and <code class="literal">/decrypt</code> endpoints also both accept paths in the form of <code class="literal">/*/{name}/{profiles}</code>, which can be used to control cryptography on a per-application (name) and per-profile basis when clients call into the main environment resource.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>To control the cryptography in this granular way, you must also provide a <code class="literal">@Bean</code> of type <code class="literal">TextEncryptorLocator</code> that creates a different encryptor per name and profiles.
|
||||
mysecret</pre><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>If you testing with curl, then use <code class="literal">--data-urlencode</code> (instead of <code class="literal">-d</code>) or set an explicit <code class="literal">Content-Type: text/plain</code> to make sure curl encodes the data correctly when there are special characters ('+' is particularly tricky).</p></td></tr></table></div><p>Take the encrypted value and add the <code class="literal">{cipher}</code> prefix before you put it in the YAML or properties file and before you commit and push it to a remote (potentially insecure) store.</p><p>The <code class="literal">/encrypt</code> and <code class="literal">/decrypt</code> endpoints also both accept paths in the form of <code class="literal">/*/{application}/{profiles}</code>, which can be used to control cryptography on a per-application (name) and per-profile basis when clients call into the main environment resource.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>To control the cryptography in this granular way, you must also provide a <code class="literal">@Bean</code> of type <code class="literal">TextEncryptorLocator</code> that creates a different encryptor per name and profiles.
|
||||
The one that is provided by default does not do so (all encryptions use the same key).</p></td></tr></table></div><p>The <code class="literal">spring</code> command line client (with Spring Cloud CLI extensions
|
||||
installed) can also be used to encrypt and decrypt, as shown in the following example:</p><pre class="screen">$ spring encrypt mysecret --key foo
|
||||
682bc583f4641835fa2db009355293665d2647dade3375c0ee201de2a49f7bda
|
||||
@@ -577,7 +577,7 @@ This is a useful feature for consumers that do not know about the Spring placeho
|
||||
For example, the JSON is structured as an ordered list of property sources, with names that correlate with the source.
|
||||
The YAML and properties forms are coalesced into a single map, even if the origin of the values has multiple sources, and the names of the original source files are lost.
|
||||
Also, the YAML representation is not necessarily a faithful representation of the YAML source in a backing repository either. It is constructed from a list of flat property sources, and assumptions have to be made about the form of the keys.</p></td></tr></table></div></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="_serving_plain_text" href="#_serving_plain_text"></a>4. Serving Plain Text</h1></div></div></div><p>Instead of using the <code class="literal">Environment</code> abstraction (or one of the alternative representations of it in YAML or properties format), your applications might need generic plain-text configuration files that are tailored to their environment.
|
||||
The Config Server provides these through an additional endpoint at <code class="literal">/{name}/{profile}/{label}/{path}</code>, where <code class="literal">name</code>, <code class="literal">profile</code>, and <code class="literal">label</code> have the same meaning as the regular environment endpoint, but <code class="literal">path</code> is a file name (such as <code class="literal">log.xml</code>).
|
||||
The Config Server provides these through an additional endpoint at <code class="literal">/{application}/{profile}/{label}/{path}</code>, where <code class="literal">application</code>, <code class="literal">profile</code>, and <code class="literal">label</code> have the same meaning as the regular environment endpoint, but <code class="literal">path</code> is a path to a file name (such as <code class="literal">log.xml</code>).
|
||||
The source files for this endpoint are located in the same way as for the environment endpoints.
|
||||
The same search path is used for properties and YAML files.
|
||||
However, instead of aggregating all matching resources, only the first one to match is returned.</p><p>After a resource is located, placeholders in the normal format (<code class="literal">${…​}</code>) are resolved by using the effective <code class="literal">Environment</code> for the supplied application name, profile, and label.
|
||||
@@ -632,8 +632,8 @@ If you add a dependency on the <code class="literal">spring-cloud-config-monitor
|
||||
The change detection can be strategized.
|
||||
However, by default, it looks for changes in files that match the application name (for example, <code class="literal">foo.properties</code> is targeted at the <code class="literal">foo</code> application, while <code class="literal">application.properties</code> is targeted at all applications).
|
||||
The strategy to use when you want to override the behavior is <code class="literal">PropertyPathNotificationExtractor</code>, which accepts the request headers and body as parameters and returns a list of file paths that changed.</p><p>The default configuration works out of the box with Github, Gitlab, Gitea, Gitee, Gogs or Bitbucket.
|
||||
In addition to the JSON notifications from Github, Gitlab, Gitee, or Bitbucket, you can trigger a change notification by POSTing to <code class="literal">/monitor</code> with form-encoded body parameters in the pattern of <code class="literal">path={name}</code>.
|
||||
Doing so broadcasts to applications matching the <code class="literal">{name}</code> pattern (which can contain wildcards).</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>The <code class="literal">RefreshRemoteApplicationEvent</code> is transmitted only if the <code class="literal">spring-cloud-bus</code> is activated in both the Config Server and in the client application.</p></td></tr></table></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>The default configuration also detects filesystem changes in local git repositories. In that case, the webhook is not used. However, as soon as you edit a config file, a refresh is broadcast.</p></td></tr></table></div></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="_spring_cloud_config_client" href="#_spring_cloud_config_client"></a>7. Spring Cloud Config Client</h1></div></div></div><p>A Spring Boot application can take immediate advantage of the Spring Config Server (or other external property sources provided by the application developer).
|
||||
In addition to the JSON notifications from Github, Gitlab, Gitee, or Bitbucket, you can trigger a change notification by POSTing to <code class="literal">/monitor</code> with form-encoded body parameters in the pattern of <code class="literal">path={application}</code>.
|
||||
Doing so broadcasts to applications matching the <code class="literal">{application}</code> pattern (which can contain wildcards).</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>The <code class="literal">RefreshRemoteApplicationEvent</code> is transmitted only if the <code class="literal">spring-cloud-bus</code> is activated in both the Config Server and in the client application.</p></td></tr></table></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>The default configuration also detects filesystem changes in local git repositories. In that case, the webhook is not used. However, as soon as you edit a config file, a refresh is broadcast.</p></td></tr></table></div></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="_spring_cloud_config_client" href="#_spring_cloud_config_client"></a>7. Spring Cloud Config Client</h1></div></div></div><p>A Spring Boot application can take immediate advantage of the Spring Config Server (or other external property sources provided by the application developer).
|
||||
It also picks up some additional useful features related to <code class="literal">Environment</code> change events.</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="config-first-bootstrap" href="#config-first-bootstrap"></a>7.1 Config First Bootstrap</h2></div></div></div><p>The default behavior for any application that has the Spring Cloud Config Client on the classpath is as follows:
|
||||
When a config client starts, it binds to the Config Server (through the <code class="literal">spring.cloud.config.uri</code> bootstrap configuration property) and initializes Spring <code class="literal">Environment</code> with remote property sources.</p><p>The net result of this behavior is that all client applications that want to consume the Config Server need a <code class="literal">bootstrap.yml</code> (or an environment variable) with the server address set in <code class="literal">spring.cloud.config.uri</code> (it defaults to "http://localhost:8888").</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="discovery-first-bootstrap" href="#discovery-first-bootstrap"></a>7.2 Discovery First Bootstrap</h2></div></div></div><p>If you use a <code class="literal">DiscoveryClient</code> implementation, such as Spring Cloud Netflix and Eureka Service Discovery or Spring Cloud Consul, you can have the Config Server register with the Discovery Service.
|
||||
However, in the default <span class="quote">“<span class="quote">Config First</span>”</span> mode, clients cannot take advantage of the registration.</p><p>If you prefer to use <code class="literal">DiscoveryClient</code> to locate the Config Server, you can do so by setting <code class="literal">spring.cloud.config.discovery.enabled=true</code> (the default is <code class="literal">false</code>).
|
||||
@@ -659,7 +659,7 @@ First, you need to set <code class="literal">spring.cloud.config.fail-fast=true<
|
||||
Then you need to add <code class="literal">spring-retry</code> and <code class="literal">spring-boot-starter-aop</code> to your classpath.
|
||||
The default behavior is to retry six 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) by setting the <code class="literal">spring.cloud.config.retry.*</code> configuration properties.</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>To take full control of the retry behavior, add a <code class="literal">@Bean</code> of type <code class="literal">RetryOperationsInterceptor</code> with an ID of <code class="literal">configServerRetryInterceptor</code>.
|
||||
Spring Retry has a <code class="literal">RetryInterceptorBuilder</code> that supports creating one.</p></td></tr></table></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_locating_remote_configuration_resources" href="#_locating_remote_configuration_resources"></a>7.5 Locating Remote Configuration Resources</h2></div></div></div><p>The Config Service serves property sources from <code class="literal">/{name}/{profile}/{label}</code>, where the default bindings in the client app are as follows:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">"name" = <code class="literal">${spring.application.name}</code></li><li class="listitem">"profile" = <code class="literal">${spring.profiles.active}</code> (actually <code class="literal">Environment.getActiveProfiles()</code>)</li><li class="listitem">"label" = "master"</li></ul></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>When setting the property <code class="literal">${spring.application.name}</code> do not prefix your app name with the reserved word <code class="literal">application-</code> to prevent issues resolving the correct property source.</p></td></tr></table></div><p>You can override all of them by setting <code class="literal">spring.cloud.config.*</code> (where <code class="literal">*</code> is <code class="literal">name</code>, <code class="literal">profile</code> or <code class="literal">label</code>).
|
||||
Spring Retry has a <code class="literal">RetryInterceptorBuilder</code> that supports creating one.</p></td></tr></table></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_locating_remote_configuration_resources" href="#_locating_remote_configuration_resources"></a>7.5 Locating Remote Configuration Resources</h2></div></div></div><p>The Config Service serves property sources from <code class="literal">/{application}/{profile}/{label}</code>, where the default bindings in the client app are as follows:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">"name" = <code class="literal">${spring.application.name}</code></li><li class="listitem">"profile" = <code class="literal">${spring.profiles.active}</code> (actually <code class="literal">Environment.getActiveProfiles()</code>)</li><li class="listitem">"label" = "master"</li></ul></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>When setting the property <code class="literal">${spring.application.name}</code> do not prefix your app name with the reserved word <code class="literal">application-</code> to prevent issues resolving the correct property source.</p></td></tr></table></div><p>You can override all of them by setting <code class="literal">spring.cloud.config.*</code> (where <code class="literal">*</code> is <code class="literal">name</code>, <code class="literal">profile</code> or <code class="literal">label</code>).
|
||||
The <code class="literal">label</code> is useful for rolling back to previous versions of configuration.
|
||||
With the default Config Server implementation, it can be a git label, branch name, or commit ID.
|
||||
Label can also be provided as a comma-separated list.
|
||||
|
||||
@@ -1067,7 +1067,7 @@ mysecret</screen>
|
||||
<simpara>If you testing with curl, then use <literal>--data-urlencode</literal> (instead of <literal>-d</literal>) or set an explicit <literal>Content-Type: text/plain</literal> to make sure curl encodes the data correctly when there are special characters ('+' is particularly tricky).</simpara>
|
||||
</tip>
|
||||
<simpara>Take the encrypted value and add the <literal>{cipher}</literal> prefix before you put it in the YAML or properties file and before you commit and push it to a remote (potentially insecure) store.</simpara>
|
||||
<simpara>The <literal>/encrypt</literal> and <literal>/decrypt</literal> endpoints also both accept paths in the form of <literal>/*/{name}/{profiles}</literal>, which can be used to control cryptography on a per-application (name) and per-profile basis when clients call into the main environment resource.</simpara>
|
||||
<simpara>The <literal>/encrypt</literal> and <literal>/decrypt</literal> endpoints also both accept paths in the form of <literal>/*/{application}/{profiles}</literal>, which can be used to control cryptography on a per-application (name) and per-profile basis when clients call into the main environment resource.</simpara>
|
||||
<note>
|
||||
<simpara>To control the cryptography in this granular way, you must also provide a <literal>@Bean</literal> of type <literal>TextEncryptorLocator</literal> that creates a different encryptor per name and profiles.
|
||||
The one that is provided by default does not do so (all encryptions use the same key).</simpara>
|
||||
@@ -1197,7 +1197,7 @@ Also, the YAML representation is not necessarily a faithful representation of th
|
||||
<chapter xml:id="_serving_plain_text">
|
||||
<title>Serving Plain Text</title>
|
||||
<simpara>Instead of using the <literal>Environment</literal> abstraction (or one of the alternative representations of it in YAML or properties format), your applications might need generic plain-text configuration files that are tailored to their environment.
|
||||
The Config Server provides these through an additional endpoint at <literal>/{name}/{profile}/{label}/{path}</literal>, where <literal>name</literal>, <literal>profile</literal>, and <literal>label</literal> have the same meaning as the regular environment endpoint, but <literal>path</literal> is a file name (such as <literal>log.xml</literal>).
|
||||
The Config Server provides these through an additional endpoint at <literal>/{application}/{profile}/{label}/{path}</literal>, where <literal>application</literal>, <literal>profile</literal>, and <literal>label</literal> have the same meaning as the regular environment endpoint, but <literal>path</literal> is a path to a file name (such as <literal>log.xml</literal>).
|
||||
The source files for this endpoint are located in the same way as for the environment endpoints.
|
||||
The same search path is used for properties and YAML files.
|
||||
However, instead of aggregating all matching resources, only the first one to match is returned.</simpara>
|
||||
@@ -1284,8 +1284,8 @@ The change detection can be strategized.
|
||||
However, by default, it looks for changes in files that match the application name (for example, <literal>foo.properties</literal> is targeted at the <literal>foo</literal> application, while <literal>application.properties</literal> is targeted at all applications).
|
||||
The strategy to use when you want to override the behavior is <literal>PropertyPathNotificationExtractor</literal>, which accepts the request headers and body as parameters and returns a list of file paths that changed.</simpara>
|
||||
<simpara>The default configuration works out of the box with Github, Gitlab, Gitea, Gitee, Gogs or Bitbucket.
|
||||
In addition to the JSON notifications from Github, Gitlab, Gitee, or Bitbucket, you can trigger a change notification by POSTing to <literal>/monitor</literal> with form-encoded body parameters in the pattern of <literal>path={name}</literal>.
|
||||
Doing so broadcasts to applications matching the <literal>{name}</literal> pattern (which can contain wildcards).</simpara>
|
||||
In addition to the JSON notifications from Github, Gitlab, Gitee, or Bitbucket, you can trigger a change notification by POSTing to <literal>/monitor</literal> with form-encoded body parameters in the pattern of <literal>path={application}</literal>.
|
||||
Doing so broadcasts to applications matching the <literal>{application}</literal> pattern (which can contain wildcards).</simpara>
|
||||
<note>
|
||||
<simpara>The <literal>RefreshRemoteApplicationEvent</literal> is transmitted only if the <literal>spring-cloud-bus</literal> is activated in both the Config Server and in the client application.</simpara>
|
||||
</note>
|
||||
@@ -1350,7 +1350,7 @@ Spring Retry has a <literal>RetryInterceptorBuilder</literal> that supports crea
|
||||
</section>
|
||||
<section xml:id="_locating_remote_configuration_resources">
|
||||
<title>Locating Remote Configuration Resources</title>
|
||||
<simpara>The Config Service serves property sources from <literal>/{name}/{profile}/{label}</literal>, where the default bindings in the client app are as follows:</simpara>
|
||||
<simpara>The Config Service serves property sources from <literal>/{application}/{profile}/{label}</literal>, where the default bindings in the client app are as follows:</simpara>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<simpara>"name" = <literal>${spring.application.name}</literal></simpara>
|
||||
|
||||
Reference in New Issue
Block a user