Polish documentation
Cleanup and polish some areas of the documentation.
This commit is contained in:
@@ -60,7 +60,7 @@ When reading the code, remember the following rules of thumb:
|
||||
[[howto.application.customize-the-environment-or-application-context]]
|
||||
== Customize the Environment or ApplicationContext Before It Starts
|
||||
|
||||
A `SpringApplication` has `ApplicationListeners` and `ApplicationContextInitializers` that are used to apply customizations to the context or environment.
|
||||
A `SpringApplication` has `ApplicationListener` and `ApplicationContextInitializer` implementations that are used to apply customizations to the context or environment.
|
||||
Spring Boot loads a number of such customizations for use internally from `META-INF/spring.factories`.
|
||||
There is more than one way to register additional customizations:
|
||||
|
||||
@@ -97,7 +97,7 @@ This is too late to configure certain properties such as `+logging.*+` and `+spr
|
||||
[[howto.application.context-hierarchy]]
|
||||
== Build an ApplicationContext Hierarchy (Adding a Parent or Root Context)
|
||||
|
||||
You can use the `ApplicationBuilder` class to create parent/child `ApplicationContext` hierarchies.
|
||||
You can use the `SpringApplicationBuilder` class to create parent/child `ApplicationContext` hierarchies.
|
||||
See xref:reference:features/spring-application.adoc#features.spring-application.fluent-builder-api[] in the "`Spring Boot Features`" section for more information.
|
||||
|
||||
|
||||
|
||||
@@ -566,11 +566,11 @@ You can configure the roles by using the configprop:management.endpoint.health.r
|
||||
NOTE: If you have secured your application and wish to use `always`, your security configuration must permit access to the health endpoint for both authenticated and unauthenticated users.
|
||||
|
||||
Health information is collected from the content of a javadoc:org.springframework.boot.actuate.health.HealthContributorRegistry[] (by default, all javadoc:org.springframework.boot.actuate.health.HealthContributor[] instances defined in your `ApplicationContext`).
|
||||
Spring Boot includes a number of auto-configured `HealthContributors`, and you can also write your own.
|
||||
Spring Boot includes a number of auto-configured `HealthContributor` beans, and you can also write your own.
|
||||
|
||||
A `HealthContributor` can be either a `HealthIndicator` or a `CompositeHealthContributor`.
|
||||
A `HealthIndicator` provides actual health information, including a `Status`.
|
||||
A `CompositeHealthContributor` provides a composite of other `HealthContributors`.
|
||||
A `CompositeHealthContributor` provides a composite of other `HealthContributor` instances.
|
||||
Taken together, contributors form a tree structure to represent the overall system health.
|
||||
|
||||
By default, the final system health is derived by a `StatusAggregator`, which sorts the statuses from each `HealthIndicator` based on an ordered list of statuses.
|
||||
@@ -584,7 +584,7 @@ TIP: You can use the `HealthContributorRegistry` to register and unregister heal
|
||||
[[actuator.endpoints.health.auto-configured-health-indicators]]
|
||||
=== Auto-configured HealthIndicators
|
||||
|
||||
When appropriate, Spring Boot auto-configures the `HealthIndicators` listed in the following table.
|
||||
When appropriate, Spring Boot auto-configures the `HealthIndicator` beans listed in the following table.
|
||||
You can also enable or disable selected indicators by configuring `management.health.key.enabled`,
|
||||
with the `key` listed in the following table:
|
||||
|
||||
@@ -655,7 +655,7 @@ with the `key` listed in the following table:
|
||||
|
||||
TIP: You can disable them all by setting the configprop:management.health.defaults.enabled[] property.
|
||||
|
||||
Additional `HealthIndicators` are available but are not enabled by default:
|
||||
Additional `HealthIndicator` beans are available, but are not enabled by default:
|
||||
|
||||
[cols="3,4,6"]
|
||||
|===
|
||||
@@ -752,7 +752,7 @@ The following table shows the default status mappings for the built-in statuses:
|
||||
|
||||
For reactive applications, such as those that use Spring WebFlux, `ReactiveHealthContributor` provides a non-blocking contract for getting application health.
|
||||
Similar to a traditional `HealthContributor`, health information is collected from the content of a javadoc:org.springframework.boot.actuate.health.ReactiveHealthContributorRegistry[] (by default, all javadoc:org.springframework.boot.actuate.health.HealthContributor[] and javadoc:org.springframework.boot.actuate.health.ReactiveHealthContributor[] instances defined in your `ApplicationContext`).
|
||||
Regular `HealthContributors` that do not check against a reactive API are executed on the elastic scheduler.
|
||||
Regular `HealthContributor` instances that do not check against a reactive API are executed on the elastic scheduler.
|
||||
|
||||
TIP: In a reactive application, you should use the `ReactiveHealthContributorRegistry` to register and unregister health indicators at runtime.
|
||||
If you need to register a regular `HealthContributor`, you should wrap it with `ReactiveHealthContributor#adapt`.
|
||||
@@ -769,7 +769,7 @@ TIP: To handle the error automatically, consider extending from `AbstractReactiv
|
||||
[[actuator.endpoints.health.auto-configured-reactive-health-indicators]]
|
||||
=== Auto-configured ReactiveHealthIndicators
|
||||
|
||||
When appropriate, Spring Boot auto-configures the following `ReactiveHealthIndicators`:
|
||||
When appropriate, Spring Boot auto-configures the following `ReactiveHealthIndicator` beans:
|
||||
|
||||
[cols="2,4,6"]
|
||||
|===
|
||||
|
||||
@@ -888,8 +888,8 @@ To customize the tags when using `WebClient`, provide a `@Bean` that implements
|
||||
[[actuator.metrics.supported.tomcat]]
|
||||
=== Tomcat Metrics
|
||||
|
||||
Auto-configuration enables the instrumentation of Tomcat only when an `MBeanRegistry` is enabled.
|
||||
By default, the `MBeanRegistry` is disabled, but you can enable it by setting configprop:server.tomcat.mbeanregistry.enabled[] to `true`.
|
||||
Auto-configuration enables the instrumentation of Tomcat only when an MBean `org.apache.tomcat.util.modeler.Registry` is enabled.
|
||||
By default, the MBean registry is disabled, but you can enable it by setting configprop:server.tomcat.mbeanregistry.enabled[] to `true`.
|
||||
|
||||
Tomcat metrics are published under the `tomcat.` meter name.
|
||||
|
||||
|
||||
@@ -372,7 +372,7 @@ Furthermore, you can define a `RestClientOptions` bean to take further control o
|
||||
{url-spring-data-elasticsearch-site}[Spring Data Elasticsearch] ships `ReactiveElasticsearchClient` for querying Elasticsearch instances in a reactive fashion.
|
||||
If you have Spring Data Elasticsearch and Reactor on the classpath, Spring Boot will auto-configure and register a `ReactiveElasticsearchClient`.
|
||||
|
||||
The `ReactiveElasticsearchclient` uses a transport that depends upon the previously described `RestClient`.
|
||||
The `ReactiveElasticsearchClient` uses a transport that depends upon the previously described `RestClient`.
|
||||
Therefore, the properties described previously can be used to configure the `ReactiveElasticsearchClient`.
|
||||
Furthermore, you can define a `RestClientOptions` bean to take further control of the behavior of the transport.
|
||||
|
||||
@@ -409,10 +409,10 @@ You can customize the locations to look for repositories and documents by using
|
||||
|
||||
TIP: For complete details of Spring Data Elasticsearch, see the {url-spring-data-elasticsearch-docs}[reference documentation].
|
||||
|
||||
Spring Boot supports both classic and reactive Elasticsearch repositories, using the `ElasticsearchRestTemplate` or `ReactiveElasticsearchTemplate` beans.
|
||||
Spring Boot supports both classic and reactive Elasticsearch repositories, using the `ElasticsearchTemplate` or `ReactiveElasticsearchTemplate` beans.
|
||||
Most likely those beans are auto-configured by Spring Boot given the required dependencies are present.
|
||||
|
||||
If you wish to use your own template for backing the Elasticsearch repositories, you can add your own `ElasticsearchRestTemplate` or `ElasticsearchOperations` `@Bean`, as long as it is named `"elasticsearchTemplate"`.
|
||||
If you wish to use your own template for backing the Elasticsearch repositories, you can add your own `ElasticsearchTemplate` or `ElasticsearchOperations` `@Bean`, as long as it is named `"elasticsearchTemplate"`.
|
||||
Same applies to `ReactiveElasticsearchTemplate` and `ReactiveElasticsearchOperations`, with the bean name `"reactiveElasticsearchTemplate"`.
|
||||
|
||||
You can choose to disable the repositories support with the following property:
|
||||
|
||||
@@ -125,7 +125,7 @@ If HikariCP is available, we always choose it.
|
||||
. Otherwise, if https://commons.apache.org/proper/commons-dbcp/[Commons DBCP2] is available, we use it.
|
||||
. If none of HikariCP, Tomcat, and DBCP2 are available and if Oracle UCP is available, we use it.
|
||||
|
||||
NOTE: If you use the `spring-boot-starter-jdbc` or `spring-boot-starter-data-jpa` starters, you automatically get a dependency to `HikariCP`.
|
||||
NOTE: If you use the `spring-boot-starter-jdbc` or `spring-boot-starter-data-jpa` starters, you automatically get a dependency to HikariCP.
|
||||
|
||||
You can bypass that algorithm completely and specify the connection pool to use by setting the configprop:spring.datasource.type[] property.
|
||||
This is especially important if you run your application in a Tomcat container, as `tomcat-jdbc` is provided by default.
|
||||
|
||||
@@ -172,7 +172,7 @@ TIP: If multiple auto-configurations have to be defined, there is no need to ord
|
||||
|
||||
Each test can use the runner to represent a particular use case.
|
||||
For instance, the sample below invokes a user configuration (`UserConfiguration`) and checks that the auto-configuration backs off properly.
|
||||
Invoking `run` provides a callback context that can be used with `AssertJ`.
|
||||
Invoking `run` provides a callback context that can be used with AssertJ.
|
||||
|
||||
include-code::MyServiceAutoConfigurationTests[tag=test-user-config]
|
||||
|
||||
|
||||
@@ -195,7 +195,7 @@ You can use this prefix with the `spring.config.location` and `spring.config.add
|
||||
|
||||
For example, a `spring.config.import` value of `optional:file:./myconfig.properties` allows your application to start, even if the `myconfig.properties` file is missing.
|
||||
|
||||
If you want to ignore all `ConfigDataLocationNotFoundExceptions` and always continue to start your application, you can use the `spring.config.on-not-found` property.
|
||||
If you want to ignore all `ConfigDataLocationNotFoundException` errors and always continue to start your application, you can use the `spring.config.on-not-found` property.
|
||||
Set the value to `ignore` using `SpringApplication.setDefaultProperties(...)` or with a system/environment variable.
|
||||
|
||||
|
||||
@@ -1082,7 +1082,7 @@ NOTE: The preceding merging rules apply to properties from all property sources,
|
||||
=== Properties Conversion
|
||||
|
||||
Spring Boot attempts to coerce the external application properties to the right type when it binds to the `@ConfigurationProperties` beans.
|
||||
If you need custom type conversion, you can provide a `ConversionService` bean (with a bean named `conversionService`) or custom property editors (through a `CustomEditorConfigurer` bean) or custom `Converters` (with bean definitions annotated as `@ConfigurationPropertiesBinding`).
|
||||
If you need custom type conversion, you can provide a `ConversionService` bean (with a bean named `conversionService`) or custom property editors (through a `CustomEditorConfigurer` bean) or custom converters (with bean definitions annotated as `@ConfigurationPropertiesBinding`).
|
||||
|
||||
NOTE: As this bean is requested very early during the application lifecycle, make sure to limit the dependencies that your `ConversionService` is using.
|
||||
Typically, any dependency that you require may not be fully initialized at creation time.
|
||||
|
||||
@@ -28,7 +28,7 @@ TIP: To add additional logging during startup, you can override `logStartupInfo(
|
||||
[[features.spring-application.startup-failure]]
|
||||
== Startup Failure
|
||||
|
||||
If your application fails to start, registered `FailureAnalyzers` get a chance to provide a dedicated error message and a concrete action to fix the problem.
|
||||
If your application fails to start, registered `FailureAnalyzer` beans get a chance to provide a dedicated error message and a concrete action to fix the problem.
|
||||
For instance, if you start a web application on port `8080` and that port is already in use, you should see something similar to the following message:
|
||||
|
||||
[source]
|
||||
|
||||
@@ -101,7 +101,7 @@ NOTE: When a cache library offers both a native implementation and JSR-107 suppo
|
||||
TIP: Spring Boot has xref:io/hazelcast.adoc[general support for Hazelcast].
|
||||
If a single `HazelcastInstance` is available, it is automatically reused for the `CacheManager` as well, unless the configprop:spring.cache.jcache.config[] property is specified.
|
||||
|
||||
There are two ways to customize the underlying `javax.cache.cacheManager`:
|
||||
There are two ways to customize the underlying `javax.cache.CacheManager`:
|
||||
|
||||
* Caches can be created on startup by setting the configprop:spring.cache.cache-names[] property.
|
||||
If a custom `javax.cache.configuration.Configuration` bean is defined, it is used to customize them.
|
||||
|
||||
@@ -71,7 +71,7 @@ To use the factory bean, wire `StreamsBuilder` into your `@Bean` as shown in the
|
||||
|
||||
include-code::MyKafkaStreamsConfiguration[]
|
||||
|
||||
By default, the streams managed by the `StreamBuilder` object are started automatically.
|
||||
By default, the streams managed by the `StreamsBuilder` object are started automatically.
|
||||
You can customize this behavior using the configprop:spring.kafka.streams.auto-startup[] property.
|
||||
|
||||
|
||||
|
||||
@@ -319,7 +319,7 @@ The following example shows a test class for Jackson:
|
||||
include-code::MyJsonTests[]
|
||||
|
||||
NOTE: JSON helper classes can also be used directly in standard unit tests.
|
||||
To do so, call the `initFields` method of the helper in your `@Before` method if you do not use `@JsonTest`.
|
||||
To do so, call the `initFields` method of the helper in your `@BeforeEach` method if you do not use `@JsonTest`.
|
||||
|
||||
If you use Spring Boot's AssertJ-based helpers to assert on a number value at a given JSON path, you might not be able to use `isEqualTo` depending on the type.
|
||||
Instead, you can use AssertJ's `satisfies` to assert that the value matches the given condition.
|
||||
@@ -503,7 +503,7 @@ include-code::MyDataCouchbaseTests[]
|
||||
== Auto-configured Data Elasticsearch Tests
|
||||
|
||||
You can use `@DataElasticsearchTest` to test Elasticsearch applications.
|
||||
By default, it configures an `ElasticsearchRestTemplate`, scans for `@Document` classes, and configures Spring Data Elasticsearch repositories.
|
||||
By default, it configures an `ElasticsearchTemplate`, scans for `@Document` classes, and configures Spring Data Elasticsearch repositories.
|
||||
Regular `@Component` and `@ConfigurationProperties` beans are not scanned when the `@DataElasticsearchTest` annotation is used.
|
||||
`@EnableConfigurationProperties` can be used to include `@ConfigurationProperties` beans.
|
||||
(For more about using Elasticsearch with Spring Boot, see xref:data/nosql.adoc#data.nosql.elasticsearch[], earlier in this chapter.)
|
||||
@@ -809,7 +809,7 @@ include-code::MyRestDocsConfiguration[]
|
||||
=== Auto-configured Spring Web Services Client Tests
|
||||
|
||||
You can use `@WebServiceClientTest` to test applications that call web services using the Spring Web Services project.
|
||||
By default, it configures a mock `WebServiceServer` bean and automatically customizes your `WebServiceTemplateBuilder`.
|
||||
By default, it configures a `MockWebServiceServer` bean and automatically customizes your `WebServiceTemplateBuilder`.
|
||||
(For more about using Web Services with Spring Boot, see xref:io/webservices.adoc[].)
|
||||
|
||||
|
||||
|
||||
@@ -30,9 +30,9 @@ include-code::MyEnvironmentTests[]
|
||||
|
||||
|
||||
[[testing.utilities.output-capture]]
|
||||
== OutputCapture
|
||||
== OutputCaptureExtension
|
||||
|
||||
`OutputCapture` is a JUnit `Extension` that you can use to capture `System.out` and `System.err` output.
|
||||
`OutputCaptureExtension` is a JUnit `Extension` that you can use to capture `System.out` and `System.err` output.
|
||||
To use it, add `@ExtendWith(OutputCaptureExtension.class)` and inject `CapturedOutput` as an argument to your test class constructor or test method as follows:
|
||||
|
||||
include-code::MyOutputCaptureTests[]
|
||||
|
||||
@@ -486,7 +486,7 @@ To avoid this limitation, the `packages` method should not be used, and endpoint
|
||||
|
||||
For more advanced customizations, you can also register an arbitrary number of beans that implement `ResourceConfigCustomizer`.
|
||||
|
||||
All the registered endpoints should be `@Components` with HTTP resource annotations (`@GET` and others), as shown in the following example:
|
||||
All the registered endpoints should be a `@Component` with HTTP resource annotations (`@GET` and others), as shown in the following example:
|
||||
|
||||
include-code::MyEndpoint[]
|
||||
|
||||
|
||||
@@ -107,8 +107,7 @@ The GraphQL WebSocket endpoint is off by default. To enable it:
|
||||
|
||||
Spring GraphQL provides a {url-spring-graphql-docs}/transports.html#server.interception[Web Interception] model.
|
||||
This is quite useful for retrieving information from an HTTP request header and set it in the GraphQL context or fetching information from the same context and writing it to a response header.
|
||||
With Spring Boot, you can declare a `WebInterceptor` bean to have it registered with the web transport.
|
||||
|
||||
With Spring Boot, you can declare a `WebGraphQlInterceptor` bean to have it registered with the web transport.
|
||||
|
||||
{url-spring-framework-docs}/web/webmvc-cors.html[Spring MVC] and {url-spring-framework-docs}/web/webflux-cors.html[Spring WebFlux] support CORS (Cross-Origin Resource Sharing) requests.
|
||||
CORS is a critical part of the web config for GraphQL applications that are accessed from browsers using different domains.
|
||||
|
||||
Reference in New Issue
Block a user