java version of spring cloud + spring boot social e-commerce platform - the context of service

Spring Boot for how to use Spring to build an application has a view: for example, it has a regular position in the regular profiles, as well as endpoints for common management and monitoring tasks. Spring Cloud builds on this, and added a number of possible system or component will use all the functions required occasionally.

Boot application context
a Spring Cloud application by creating a "bootstrap" operation context, the context is the main application of the parent context. Out of the box, is responsible for loading configuration properties from an external source, but also decryption local external configuration file attributes. Both share a context Environment, which is the source of any external properties Spring application. Bootstrap attribute high priority, and therefore can not be configured to cover the local default.

Guiding the context in the main application context different external configuration convention, so use bootstrap.yml application.yml (or .properties) instead of the guide and the external configuration of the master context. example:

bootstrap.yml

spring:
  application:
    name: foo
  cloud:
    config:
      uri: ${SPRING_CONFIG_URI:http://localhost:8888}

If your application requires an application-specific configurations on the server, then set spring.application.name is a good idea (or at bootstrap.yml application.yml) in.

You can set spring.cloud.bootstrap.enabled = false (e.g. in the system properties) to completely disable the boot process.

Application context hierarchy
If you build an application context from SpringApplication or SpringApplicationBuilder, Bootstrap will add context for the context of the parent. This is a Spring function, namely sub-context inherit attributes of the source and configuration files from its parent, compared with the same context constructed without the use of Spring Cloud Config, "main" application context will include other properties of the source. Additional sources of property are:

"Bootstrap": if any of the Bootstrap PropertySourceLocators context, the optional CompositePropertySource display as a high priority, and has a non-empty properties. One example is the attribute from Spring Cloud Config server. For instructions on how to customize the content of this attribute sources, see below.

"ApplicationConfig: [classpath: bootstrap.yml]" (if Spring configuration file is active, for the friends). If you have a bootstrap.yml (or attributes), then these properties are used to configure the boot context, and then when the parent is set to add them to the child context. Their priority is lower than application.yml (or attributes) and added as a normal part of creating Spring Boot application process to any other source sub-level attributes. For instructions on how to customize the content of these sources of properties, see below.

Since the properties of the source of collation, "Boot" entry in priority, but note that these entries do not contain any data from bootstrap.yml, it has a very low priority, but can be used to set the default value.

You can simply set any parent ApplicationContext that you create a context to expand the context hierarchy, for example, use their own interface or use SpringApplicationBuilder convenient method (parent (), child () and sibling ()). Boot environment that you create your own highest-level ancestor parent. Each context hierarchy will have its own "guide" properties of the source (possibly empty), to avoid inadvertent upgrade the value from the parent to its offspring. Each context hierarchy, so that if there is a configuration server, the remote property different sources. Common rules application context behavior Spring applies to property analysis: sub-environment property overrides the parent of the attribute by name and attribute source name (if the child has with the parent of the same name attribute source and one from the parents of children do not including in children).
JAVASpring Cloud needs of large enterprises distributed micro cloud services built B2B2C e-commerce platform source code, please add penguin beg: 3536247259

Guess you like

Origin www.cnblogs.com/itcode-code/p/11161776.html