Sync docs from master to gh-pages
This commit is contained in:
@@ -449,10 +449,12 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
|
||||
<li><a href="#_spring_cloud_config_server">Spring Cloud Config Server</a>
|
||||
<ul class="sectlevel2">
|
||||
<li><a href="#_environment_repository">Environment Repository</a></li>
|
||||
<li><a href="#_health_indicator">Health Indicator</a></li>
|
||||
<li><a href="#_security">Security</a></li>
|
||||
<li><a href="#_encryption_and_decryption_2">Encryption and Decryption</a></li>
|
||||
<li><a href="#_key_management">Key Management</a></li>
|
||||
<li><a href="#_creating_a_key_store_for_testing">Creating a Key Store for Testing</a></li>
|
||||
<li><a href="#_using_multiple_keys_and_key_rotation">Using Multiple Keys and Key Rotation</a></li>
|
||||
<li><a href="#_embedding_the_config_server">Embedding the Config Server</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
@@ -489,6 +491,8 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
|
||||
</li>
|
||||
<li><a href="#_circuit_breaker_hystrix_clients">Circuit Breaker: Hystrix Clients</a>
|
||||
<ul class="sectlevel2">
|
||||
<li><a href="#_propagating_the_security_context_or_using_spring_scopes">Propagating the Security Context or using Spring Scopes</a></li>
|
||||
<li><a href="#_health_indicator_2">Health Indicator</a></li>
|
||||
<li><a href="#_hystrix_metrics_stream">Hystrix Metrics Stream</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
@@ -504,6 +508,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
|
||||
<li><a href="#_customizing_the_ribbon_client">Customizing the Ribbon Client</a></li>
|
||||
<li><a href="#_using_ribbon_with_eureka">Using Ribbon with Eureka</a></li>
|
||||
<li><a href="#spring-cloud-ribbon-without-eureka">Example: How to Use Ribbon Without Eureka</a></li>
|
||||
<li><a href="#_example_disable_eureka_use_in_ribbon">Example: Disable Eureka use in Ribbon</a></li>
|
||||
<li><a href="#_using_the_ribbon_api_directly">Using the Ribbon API Directly</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
@@ -514,6 +519,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
|
||||
<li><a href="#netflix-zuul-reverse-proxy">Embedded Zuul Reverse Proxy</a></li>
|
||||
<li><a href="#_uploading_files_through_zuul">Uploading Files through Zuul</a></li>
|
||||
<li><a href="#_plain_embedded_zuul">Plain Embedded Zuul</a></li>
|
||||
<li><a href="#_disable_zuul_filters">Disable Zuul Filters</a></li>
|
||||
<li><a href="#_polyglot_support_with_sidecar">Polyglot support with Sidecar</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
@@ -524,6 +530,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
|
||||
<li><a href="#_quick_start_2">Quick Start</a></li>
|
||||
<li><a href="#_addressing_an_instance">Addressing an Instance</a></li>
|
||||
<li><a href="#_addressing_all_instances_of_a_service">Addressing all instances of a service</a></li>
|
||||
<li><a href="#_application_context_id_must_be_unique">Application Context ID must be unique</a></li>
|
||||
<li><a href="#_customizing_the_amqp_connectionfactory_2">Customizing the AMQP ConnectionFactory</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
@@ -545,6 +552,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
|
||||
<li><a href="#_more_detail">More Detail</a>
|
||||
<ul class="sectlevel2">
|
||||
<li><a href="#_single_sign_on">Single Sign On</a></li>
|
||||
<li><a href="#_token_type_in_user_info">Token Type in User Info</a></li>
|
||||
<li><a href="#_customizing_the_resttemplate">Customizing the RestTemplate</a></li>
|
||||
<li><a href="#_resource_server">Resource Server</a></li>
|
||||
<li><a href="#_token_relay">Token Relay</a></li>
|
||||
@@ -623,6 +631,25 @@ and extensibility mechanism to cover others.</p>
|
||||
<p>Many of those features are covered by <a href="http://projects.spring.io/spring-boot">Spring Boot</a>, which we build on in Spring Cloud. Some more are delivered by Spring Cloud as two libraries: Spring Cloud Context and Spring Cloud Commons. Spring Cloud Context provides utilities and special services for the <code>ApplicationContext</code> of a Spring Cloud application (bootstrap context, encryption, refresh scope and environment endpoints). Spring Cloud Commons is a set of abstractions and common classes used in different Spring Cloud implementations (eg. Spring Cloud Netflix vs. Spring Cloud Consul).</p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>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:</p>
|
||||
</div>
|
||||
<div class="ulist">
|
||||
<ul>
|
||||
<li>
|
||||
<p>Java 6 JCE Link <a href="http://www.oracle.com/technetwork/java/javase/downloads/jce-6-download-429243.html" class="bare">http://www.oracle.com/technetwork/java/javase/downloads/jce-6-download-429243.html</a></p>
|
||||
</li>
|
||||
<li>
|
||||
<p>Java 7 JCE Link <a href="http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html" class="bare">http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html</a></p>
|
||||
</li>
|
||||
<li>
|
||||
<p>Java 8 JCE Link <a href="http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html" class="bare">http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html</a></p>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>Extract files into JDK/jre/lib/security folder (whichever version of JRE/JDK x64/x86 you are using).</p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p><a href="https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/docs/src/main/asciidoc/contributing-docs.adoc" class="bare">https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/docs/src/main/asciidoc/contributing-docs.adoc</a></p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -954,8 +981,10 @@ application context gets the <code>Environment</code>. To use the encryption
|
||||
features in a client you need to include Spring Security RSA in your
|
||||
classpath (Maven co-ordinates
|
||||
"org.springframework.security:spring-security-rsa") and you also need
|
||||
the full strength JCE extensions in your JVM (google it and download
|
||||
from Oracle).</p>
|
||||
the full strength JCE extensions in your JVM.</p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>include::jce.adoc</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
@@ -1133,7 +1162,7 @@ from a git repository (which must be provided):</p>
|
||||
Boot application that depends on spring-cloud-config-client (e.g. see
|
||||
the test cases for the config-client, or the sample app). The most
|
||||
convenient way to add the dependency is via a Spring Boot starter
|
||||
<code>org.springframework.cloud:spring-cloud-starter</code>. There is also a
|
||||
<code>org.springframework.cloud:spring-cloud-starter-config</code>. There is also a
|
||||
parent pom and BOM (<code>spring-cloud-starter-parent</code>) for Maven users and a
|
||||
Spring IO version management properties file for Gradle and Spring CLI
|
||||
users. Example Maven configuration:</p>
|
||||
@@ -1144,7 +1173,7 @@ users. Example Maven configuration:</p>
|
||||
<pre class="highlight"><code class="language-xml" data-lang="xml"><parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>1.1.7.RELEASE</version>
|
||||
<version>1.2.3.RELEASE</version>
|
||||
<relativePath /> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
@@ -1153,7 +1182,7 @@ users. Example Maven configuration:</p>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-parent</artifactId>
|
||||
<version>1.0.0.BUILD-SNAPSHOT</version>
|
||||
<version>1.0.1.RELEASE</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
@@ -1163,7 +1192,7 @@ users. Example Maven configuration:</p>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter</artifactId>
|
||||
<artifactId>spring-cloud-starter-config</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@@ -1334,7 +1363,12 @@ working copy as a cache.</p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>This repository implementation maps the <code>{label}</code> parameter of the
|
||||
HTTP resource to a git label (commit id, branch name or tag).</p>
|
||||
HTTP resource to a git label (commit id, branch name or tag). If the
|
||||
git branch or tag name contains a slash ("/") then the label in the
|
||||
HTTP URL should be specified with the special string "(_)" instead (to
|
||||
avoid ambiguity with other URL paths). Be careful with the brackets in
|
||||
the URL if you are using a command line client like curl (e.g. escape
|
||||
them from the shell with quotes '').</p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>Spring Cloud Config Server supports a single or multiple git
|
||||
@@ -1388,6 +1422,38 @@ and in the "foo/" sub-directory and also any sub-directory whose name
|
||||
begins with "bar".</p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>By default the server clones remote repositories when configuration
|
||||
is first requested. The server can be configured to clone the repositories
|
||||
at startup. For example at the top level:</p>
|
||||
</div>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre>spring:
|
||||
cloud:
|
||||
config:
|
||||
server:
|
||||
git:
|
||||
uri: https://git/common/config-repo.git
|
||||
repos:
|
||||
team-a:
|
||||
pattern: team-a-*
|
||||
cloneOnStart: true
|
||||
uri: http://git/team-a/config-repo.git
|
||||
team-b:
|
||||
pattern: team-b-*
|
||||
cloneOnStart: false
|
||||
uri: http://git/team-b/config-repo.git
|
||||
team-c:
|
||||
pattern: team-c-*
|
||||
uri: http://git/team-a/config-repo.git</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>In this example the server clones team-a’s config-repo on startup before it
|
||||
accepts any requests. All other repositories will not be cloned until
|
||||
configuration from the repository is requested.</p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>To use HTTP basic authentication on the remote repository add the
|
||||
"username" and "password" properties separately (not in the URL),
|
||||
e.g.</p>
|
||||
@@ -1463,6 +1529,37 @@ Spring Environment).</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="_health_indicator">Health Indicator</h3>
|
||||
<div class="paragraph">
|
||||
<p>Config Server comes with a Health Indicator that checks if the configured
|
||||
<code>EnvironmentRepository</code> is working. By default it asks the <code>EnvironmentRepository</code>
|
||||
for an application named <code>app</code>, the <code>default</code> profile and the default
|
||||
label provided by the <code>EnvironmentRepository</code> implementation.</p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>You can configure the Health Indicator to check more applications
|
||||
along with custom profiles and custom labels, e.g.</p>
|
||||
</div>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre>spring:
|
||||
cloud:
|
||||
config:
|
||||
server:
|
||||
health:
|
||||
repositories:
|
||||
myservice:
|
||||
label: mylabel
|
||||
myservice-dev:
|
||||
name: myservice
|
||||
profiles: development</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>You can disable the Health Indicator by setting <code>spring.cloud.config.server.health.enabled=false</code>.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="_security">Security</h3>
|
||||
<div class="paragraph">
|
||||
<p>You are free to secure your Config Server in any way that makes sense
|
||||
@@ -1499,15 +1596,13 @@ in the JRE lib/security directory with the ones that you downloaded).
|
||||
</table>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>The server exposes <code>/encrypt</code> and <code>/decrypt</code> endpoints (on the
|
||||
assumption that these will be secured and only accessed by authorized
|
||||
agents). If the remote property sources contain encryted content
|
||||
<p>If the remote property sources contain encryted content
|
||||
(values starting with <code>{cipher}</code>) 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
|
||||
"at rest" (e.g. in a git repository). If a value cannot be decrypted
|
||||
it is replaced with an empty string, largely to prevent cipher text
|
||||
being used as a password in Spring Boot autconfigured HTTP basic.</p>
|
||||
being used as a password and accidentally leaking.</p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>If you are setting up a remote config repository for config client
|
||||
@@ -1520,7 +1615,7 @@ instance:</p>
|
||||
<pre>spring:
|
||||
datasource:
|
||||
username: dbuser
|
||||
password: {cipher}FKSAJDFGYOS8F7GLHAKERGFHLSAJ</pre>
|
||||
password: '{cipher}FKSAJDFGYOS8F7GLHAKERGFHLSAJ'</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
@@ -1528,7 +1623,9 @@ instance:</p>
|
||||
secret password is protected.</p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>If you are editing a remote config file you can use the Config Server
|
||||
<p>The server also exposes <code>/encrypt</code> and <code>/decrypt</code> endpoints (on the
|
||||
assumption that these will be secured and only accessed by authorized
|
||||
agents). If you are editing a remote config file you can use the Config Server
|
||||
to encrypt values by POSTing to the <code>/encrypt</code> endpoint, e.g.</p>
|
||||
</div>
|
||||
<div class="listingblock">
|
||||
@@ -1550,7 +1647,25 @@ mysecret</pre>
|
||||
<div class="paragraph">
|
||||
<p>Take the encypted value and add the <code>{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>
|
||||
to a remote, potentially insecure store. The <code>/encypt</code> and <code>/decrypt</code>
|
||||
endpoints also both accept paths of the form <code>/*/{name}/{profiles}</code>
|
||||
which can be used to control cryptography per application (name)
|
||||
and profile when clients call into the main Environment resource.</p>
|
||||
</div>
|
||||
<div class="admonitionblock note">
|
||||
<table>
|
||||
<tr>
|
||||
<td class="icon">
|
||||
<div class="title">Note</div>
|
||||
</td>
|
||||
<td class="content">
|
||||
to control the cryptography in this granular way you must also
|
||||
provide a <code>@Bean</code> of type <code>TextEncryptorLocator</code> that creates a
|
||||
different encryptor per name and profiles. The one that is provided
|
||||
by default does not do this.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>The <code>spring</code> command line client (with Spring Cloud CLI extensions
|
||||
@@ -1589,9 +1704,7 @@ it is just a single property value to configure.</p>
|
||||
<div class="paragraph">
|
||||
<p>To configure a symmetric key you just need to set <code>encrypt.key</code> to a
|
||||
secret String (or use an enviroment variable <code>ENCRYPT_KEY</code> to keep it
|
||||
out of plain text configuration files). You can also POST a key value
|
||||
to the <code>/key</code> endpoint (but that won’t change any existing encrypted
|
||||
values in remote repositories).</p>
|
||||
out of plain text configuration files).</p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>To configure an asymmetric key you can either set the key as a
|
||||
@@ -1653,6 +1766,57 @@ your <code>application.yml</code> for the Config Server:</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="_using_multiple_keys_and_key_rotation">Using Multiple Keys and Key Rotation</h3>
|
||||
<div class="paragraph">
|
||||
<p>In addition to the <code>{cipher}</code> prefix in encrypted property values, the
|
||||
Config Server looks for <code>{name:value}</code> prefixes (zero or many) before
|
||||
the start of the (Base64 encoded) cipher text. The keys are passed to
|
||||
a <code>TextEncryptorLocator</code> which can do whatever logic it needs to
|
||||
locate a <code>TextEncryptor</code> for the cipher. If you have configured a
|
||||
keystore (<code>encrypt.keystore.location</code>) the default locator will look
|
||||
for keys in the store with aliases as supplied by the "key" prefix,
|
||||
i.e. with a cipher text like this:</p>
|
||||
</div>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre>foo:
|
||||
bar: `{cipher}{key:testkey}...`</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>the locator will look for a key named "testkey". A secret can also be
|
||||
supplied via a <code>{secret:…​}</code> value in the prefix, but if it is not
|
||||
the default is to use the keystore password (which is what you get
|
||||
when you build a keytore and don’t specify a secret). If you <strong>do</strong>
|
||||
supply a secret it is recommended that you also encrypt the secrets
|
||||
using a custom <code>SecretLocator</code>.</p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>Key rotation is hardly ever necessary on cryptographic grounds if the
|
||||
keys are only being used to encrypt a few bytes of configuration data
|
||||
(i.e. they are not being used elsewhere), but occasionally you might
|
||||
need to change the keys if there is a security breach for instance. In
|
||||
that case all the clients would need to change their source config
|
||||
files (e.g. in git) and use a new <code>{key:…​}</code> prefix in all the
|
||||
ciphers, checking beforehand of course that the key alias is available
|
||||
in the Config Server keystore.</p>
|
||||
</div>
|
||||
<div class="admonitionblock tip">
|
||||
<table>
|
||||
<tr>
|
||||
<td class="icon">
|
||||
<div class="title">Tip</div>
|
||||
</td>
|
||||
<td class="content">
|
||||
the <code>{name:value}</code> prefixes can also be added to plaintext posted
|
||||
to the <code>/encrypt</code> endpoint, if you want to let the Config Server
|
||||
handle all encryption as well as decryption.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="_embedding_the_config_server">Embedding the Config Server</h3>
|
||||
<div class="paragraph">
|
||||
<p>The Config Server runs best as a standalone application, but if you
|
||||
@@ -1732,8 +1896,7 @@ an Exception.</p>
|
||||
<div class="sect2">
|
||||
<h3 id="_locating_remote_configuration_resources">Locating Remote Configuration Resources</h3>
|
||||
<div class="paragraph">
|
||||
<p>The Config Service serves property sources from <code>/{name}/{env}/{label}</code>, where the default bindings in the
|
||||
client app are</p>
|
||||
<p>The Config Service serves property sources from <code>/{name}/{env}/{label}</code>, where the default bindings in the client app are</p>
|
||||
</div>
|
||||
<div class="ulist">
|
||||
<ul>
|
||||
@@ -1753,7 +1916,11 @@ client app are</p>
|
||||
(where <code>*</code> is "name", "env" or "label"). The "label" 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.</p>
|
||||
commit id. Label can also be provided as a comma-separated list, in
|
||||
which case the items in the list are tried on-by-one until one succeeds.
|
||||
This can be useful when working on a feature branch, for instance,
|
||||
when you might want to align the config label with your branch, but
|
||||
make it optional (e.g. <code>spring.cloud.config.label=myfeature,develop</code>).</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
@@ -1835,7 +2002,7 @@ Intelligent Routing (Zuul) and Client Side Load Balancing (Ribbon).
|
||||
<div class="sect2">
|
||||
<h3 id="_registering_with_eureka">Registering with Eureka</h3>
|
||||
<div class="paragraph">
|
||||
<p>When a client registers with Eureka, it provide meta-data about itself
|
||||
<p>When a client registers with Eureka, it provides meta-data about itself
|
||||
such as host and port, health indicator URL, home page etc. Eureka
|
||||
receives heartbeat messages from each instance belonging to a service.
|
||||
If the heartbeat fails over a configurable timetable, the instance is
|
||||
@@ -2099,57 +2266,6 @@ normal Eureka functionality under <code>/eureka/*</code>.</p>
|
||||
</td>
|
||||
<td class="content">
|
||||
<div class="paragraph">
|
||||
<p>You can run the Eureka server as an executable JAR (or WAR) using the
|
||||
<a href="http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#build-tool-plugins">Spring
|
||||
Boot build tools</a>, but to avoid problems with classpath scanning in
|
||||
Jersey 1.x you have to tell the build plugins to unpack the jars that
|
||||
contain JAX-RS resources, e.g. (for Maven)</p>
|
||||
</div>
|
||||
<div class="listingblock">
|
||||
<div class="title">pom.xml</div>
|
||||
<div class="content">
|
||||
<pre class="highlight"><code class="language-xml" data-lang="xml"><plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<requiresUnpack>
|
||||
<dependency>
|
||||
<groupId>com.netflix.eureka</groupId>
|
||||
<artifactId>eureka-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.netflix.eureka</groupId>
|
||||
<artifactId>eureka-client</artifactId>
|
||||
</dependency>
|
||||
</requiresUnpack>
|
||||
</configuration>
|
||||
</plugin></code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>or with Gradle</p>
|
||||
</div>
|
||||
<div class="listingblock">
|
||||
<div class="title">build.gradle</div>
|
||||
<div class="content">
|
||||
<pre class="highlight"><code class="language-java" data-lang="java">apply plugin: 'spring-boot'
|
||||
springBoot {
|
||||
requiresUnpack = ['com.netflix.eureka:eureka-core','com.netflix.eureka:eureka-client']
|
||||
}</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="admonitionblock tip">
|
||||
<table>
|
||||
<tr>
|
||||
<td class="icon">
|
||||
<div class="title">Tip</div>
|
||||
</td>
|
||||
<td class="content">
|
||||
<div class="paragraph">
|
||||
<p>Due to Gradle’s dependency resolution rules and the lack of a parent bom feature, simply depending on spring-cloud-starter-eureka-server can cause failures on application startup. To remedy this the Spring dependency management plugin must be added and the Spring cloud starter parent bom must be imported like so:</p>
|
||||
</div>
|
||||
<div class="listingblock">
|
||||
@@ -2354,6 +2470,30 @@ attribute with a list of <code>@HystrixProperty</code> annotations. See
|
||||
for more details. See the <a href="https://github.com/Netflix/Hystrix/wiki/Configuration">Hystrix wiki</a>
|
||||
for details on the properties available.</p>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="_propagating_the_security_context_or_using_spring_scopes">Propagating the Security Context or using Spring Scopes</h3>
|
||||
<div class="paragraph">
|
||||
<p>If you want some thread local context to propagate into a <code>@HystrixCommand</code> the default declaration will not work because it executes the command in a thread pool (in case of timeouts). You can switch Hystrix to use the same thread as the caller using some configuration, or directly in the annotation, by asking it to use a different "Isolation Strategy". For example:</p>
|
||||
</div>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre class="highlight"><code class="language-java" data-lang="java">@HystrixCommand(fallbackMethod = "stubMyService",
|
||||
commandProperties = {
|
||||
@HystrixProperty(name="execution.isolation.strategy", value="SEMAPHORE")
|
||||
}
|
||||
)
|
||||
...</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>The same thing applies if you are using <code>@SessionScope</code> or <code>@RequestScope</code>. You will know when you need to do this because of a runtime exception that says it can’t find the scoped context.</p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>In particular you might be interested</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="_health_indicator_2">Health Indicator</h3>
|
||||
<div class="paragraph">
|
||||
<p>The state of the connected circuit breakers are also exposed in the
|
||||
<code>/health</code> endpoint of the calling application.</p>
|
||||
@@ -2371,6 +2511,7 @@ for details on the properties available.</p>
|
||||
}</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="_hystrix_metrics_stream">Hystrix Metrics Stream</h3>
|
||||
<div class="paragraph">
|
||||
@@ -2427,7 +2568,7 @@ for details on the properties available.</p>
|
||||
aggregator:
|
||||
clusterConfig: SYSTEM,USER
|
||||
appConfig: customers,stores,ui,admin
|
||||
clusterNameExpression: metadata.cluster</pre>
|
||||
clusterNameExpression: metadata['cluster']</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
@@ -2495,7 +2636,7 @@ so if you are using <code>@FeignClient</code> then this section also applies.</p
|
||||
<div class="paragraph">
|
||||
<p>A central concept in Ribbon is that of the named client. Each load
|
||||
balancer is part of an ensemble of components that work together to
|
||||
contact a remote server on demend, and the ensemble has a name that
|
||||
contact a remote server on demand, and the ensemble has a name that
|
||||
you give it as an application developer (e.g. using the <code>@FeignClient</code>
|
||||
annotation). Spring Cloud creates a new ensemble as an
|
||||
<code>ApplicationContext</code> on demand for each named client using
|
||||
@@ -2636,6 +2777,21 @@ configuration like this</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="_example_disable_eureka_use_in_ribbon">Example: Disable Eureka use in Ribbon</h3>
|
||||
<div class="paragraph">
|
||||
<p>Setting the property <code>ribbon.eureka.enabled = false</code> will explicitly
|
||||
disable the use of Eureka in Ribbon.</p>
|
||||
</div>
|
||||
<div class="listingblock">
|
||||
<div class="title">application.yml</div>
|
||||
<div class="content">
|
||||
<pre>ribbon:
|
||||
eureka:
|
||||
enabled: false</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="_using_the_ribbon_api_directly">Using the Ribbon API Directly</h3>
|
||||
<div class="paragraph">
|
||||
<p>You can also use the <code>LoadBalancerClient</code> directly. Example:</p>
|
||||
@@ -2874,18 +3030,24 @@ level, but "/myusers/**" matches hierarchically.</p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>These simple url-routes doesn’t get executed as HystrixCommand nor can you loadbalance multiple url with Ribbon.
|
||||
To achieve this specify a service-route and configure a Ribbon client for the serviceId, e.g.</p>
|
||||
To achieve this specify a service-route and configure a Ribbon client for the
|
||||
serviceId (this currently requires disabling Eureka support in Ribbon:
|
||||
see <a href="#spring-cloud-ribbon-without-eureka">above for more information</a>), e.g.</p>
|
||||
</div>
|
||||
<div class="listingblock">
|
||||
<div class="title">application.yml</div>
|
||||
<div class="content">
|
||||
<pre class="highlight"><code class="language-yaml" data-lang="yaml"> zuul:
|
||||
<pre class="highlight"><code class="language-yaml" data-lang="yaml">zuul:
|
||||
routes:
|
||||
users:
|
||||
path: /myusers/**
|
||||
serviceId: users
|
||||
|
||||
users:
|
||||
ribbon:
|
||||
eureka:
|
||||
enabled: false
|
||||
|
||||
users:
|
||||
ribbon:
|
||||
listOfServers: example.com,google.com</code></pre>
|
||||
</div>
|
||||
@@ -2991,6 +3153,18 @@ still specified by configuring "zuul.routes.*", but there is no service discover
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="_disable_zuul_filters">Disable Zuul Filters</h3>
|
||||
<div class="paragraph">
|
||||
<p>Zuul for Spring Cloud comes with a number of <code>ZuulFilter</code> beans enabled by default
|
||||
in both proxy and server mode. See <a href="https://github.com/spring-cloud/spring-cloud-netflix/tree/master/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters">the zuul filters package</a> for the
|
||||
possible filters that are enabled. If you want to disable one, simply set
|
||||
<code>zuul.<SimpleClassName>.<filterType>.disable=true</code>. By convention, the package after
|
||||
<code>filters</code> is the Zuul filter type. For example to disable
|
||||
<code>org.springframework.cloud.netflix.zuul.filters.post.SendResponseFilter</code> set
|
||||
<code>zuul.SendResponseFilter.post.disable=true</code>.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="_polyglot_support_with_sidecar">Polyglot support with Sidecar</h3>
|
||||
<div class="paragraph">
|
||||
<p>Do you have non-jvm languages you want to take advantage of Eureka, Ribbon and
|
||||
@@ -3149,6 +3323,14 @@ info:
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect1">
|
||||
<h2 id="_application_context_id_must_be_unique">Application Context ID must be unique</h2>
|
||||
<div class="sectionbody">
|
||||
<div class="paragraph">
|
||||
<p>The bus tries to eliminate processing an event twice, once from the original <code>ApplicationEvent</code> and once from the queue. To do this, it checks the sending application context id againts the current application context id. If multiple instances of a service have the same application context id, events will not be processed. Running on a local machine, each service will be on a different port and that will be part of the application context id. Cloud Foundry supplies an index to differentiate. To ensure that the application context id is the unique, set <code>spring.application.index</code> to something unique for each instance of a service. For example, in lattice, set <code>spring.application.index=${INSTANCE_INDEX}</code> in application.properties (or bootstrap.properties if using configserver).</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect1">
|
||||
<h2 id="_customizing_the_amqp_connectionfactory_2">Customizing the AMQP ConnectionFactory</h2>
|
||||
<div class="sectionbody">
|
||||
<div class="paragraph">
|
||||
@@ -3193,7 +3375,7 @@ sure you have
|
||||
<div class="literalblock">
|
||||
<div class="content">
|
||||
<pre>$ spring version
|
||||
Spring CLI v1.2.2.RELEASE</pre>
|
||||
Spring CLI v1.2.3.RELEASE</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
@@ -3201,8 +3383,8 @@ Spring CLI v1.2.2.RELEASE</pre>
|
||||
</div>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre class="highlight"><code>$ gvm install springboot 1.2.2.RELEASE
|
||||
$ gvm use springboot 1.2.2.RELEASE</code></pre>
|
||||
<pre class="highlight"><code>$ gvm install springboot 1.2.3.RELEASE
|
||||
$ gvm use springboot 1.2.3.RELEASE</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
@@ -3211,7 +3393,7 @@ $ gvm use springboot 1.2.2.RELEASE</code></pre>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre class="highlight"><code>$ mvn install
|
||||
$ spring install org.springframework.cloud:spring-cloud-cli:1.0.1.RELEASE</code></pre>
|
||||
$ spring install org.springframework.cloud:spring-cloud-cli:1.0.2.RELEASE</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="admonitionblock important">
|
||||
@@ -3541,6 +3723,16 @@ of <code>AuthorizationCodeResourceDetails</code> so all its properties can be sp
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="_token_type_in_user_info">Token Type in User Info</h3>
|
||||
<div class="paragraph">
|
||||
<p>Google (and certain other 3rd party identity providers) is more strict
|
||||
about the token type name that is sent in the headers to the user info
|
||||
endpoint. The default is "Bearer" which suits most providers and
|
||||
matches the spec, but if you need to change it you can set
|
||||
<code>spring.oauth2.resource.tokenType</code>.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="_customizing_the_resttemplate">Customizing the RestTemplate</h3>
|
||||
<div class="paragraph">
|
||||
<p>The SSO (and Resource Server) features use an <code>OAuth2RestTemplate</code>
|
||||
@@ -3851,7 +4043,7 @@ ProxyAuthenticationProperties] for full details.</p>
|
||||
</div>
|
||||
<div id="footer">
|
||||
<div id="footer-text">
|
||||
Last updated 2015-06-23 10:34:10 UTC
|
||||
Last updated 2015-06-24 17:02:02 UTC
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user