From 711a0c19e6aabb1c21e88361c8e46576e31b2774 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Tue, 4 May 2021 10:42:11 -0700 Subject: [PATCH] Use consistent asciidoctor subs attribute Closes gh-25101 --- .../docs/asciidoc/actuator/cloud-foundry.adoc | 6 +- .../src/docs/asciidoc/actuator/enabling.adoc | 4 +- .../src/docs/asciidoc/actuator/endpoints.adoc | 56 +++++------ .../src/docs/asciidoc/actuator/jmx.adoc | 10 +- .../src/docs/asciidoc/actuator/loggers.adoc | 2 +- .../src/docs/asciidoc/actuator/metrics.adoc | 98 +++++++++---------- .../docs/asciidoc/actuator/monitoring.adoc | 16 +-- .../asciidoc/build-tool-plugins/antlib.adoc | 14 +-- .../other-build-systems.adoc | 2 +- .../docs/asciidoc/cli/groovy-beans-dsl.adoc | 2 +- .../src/docs/asciidoc/cli/using-the-cli.adoc | 24 ++--- .../annotation-processor.adoc | 16 +-- .../configuration-metadata/format.adoc | 6 +- .../configuration-metadata/manual-hints.adoc | 16 +-- .../src/docs/asciidoc/deployment/cloud.adoc | 20 ++-- .../docs/asciidoc/deployment/installing.adoc | 22 ++--- .../src/docs/asciidoc/features/caching.adoc | 24 ++--- .../asciidoc/features/container-images.adoc | 2 +- .../developing-auto-configuration.adoc | 24 ++--- .../features/developing-web-applications.adoc | 68 ++++++------- .../src/docs/asciidoc/features/email.adoc | 4 +- .../asciidoc/features/external-config.adoc | 78 +++++++-------- .../asciidoc/features/graceful-shutdown.adoc | 4 +- .../src/docs/asciidoc/features/hazelcast.adoc | 2 +- .../features/internationalization.adoc | 2 +- .../src/docs/asciidoc/features/jta.adoc | 6 +- .../src/docs/asciidoc/features/kotlin.adoc | 6 +- .../src/docs/asciidoc/features/logging.adoc | 18 ++-- .../src/docs/asciidoc/features/messaging.adoc | 56 +++++------ .../src/docs/asciidoc/features/nosql.adoc | 58 +++++------ .../src/docs/asciidoc/features/profiles.adoc | 4 +- .../src/docs/asciidoc/features/quartz.adoc | 6 +- .../docs/asciidoc/features/resttemplate.adoc | 6 +- .../src/docs/asciidoc/features/rsocket.adoc | 6 +- .../src/docs/asciidoc/features/security.adoc | 18 ++-- .../asciidoc/features/spring-application.adoc | 26 ++--- .../asciidoc/features/spring-integration.adoc | 6 +- .../asciidoc/features/spring-session.adoc | 4 +- .../src/docs/asciidoc/features/sql.adoc | 34 +++---- .../task-execution-and-scheduling.adoc | 4 +- .../src/docs/asciidoc/features/testing.adoc | 98 +++++++++---------- .../docs/asciidoc/features/validation.adoc | 2 +- .../src/docs/asciidoc/features/webclient.adoc | 2 +- .../docs/asciidoc/features/webservices.adoc | 6 +- .../docs/asciidoc/features/websockets.adoc | 2 +- .../getting-started/first-application.adoc | 14 +-- .../asciidoc/getting-started/installing.adoc | 10 +- .../src/docs/asciidoc/howto/actuator.adoc | 2 +- .../src/docs/asciidoc/howto/application.adoc | 4 +- .../src/docs/asciidoc/howto/batch.adoc | 4 +- .../src/docs/asciidoc/howto/build.adoc | 20 ++-- .../src/docs/asciidoc/howto/data-access.adoc | 42 ++++---- .../asciidoc/howto/data-initialization.adoc | 8 +- .../src/docs/asciidoc/howto/http-clients.adoc | 2 +- .../howto/jedis-instead-of-lettuce.adoc | 4 +- .../src/docs/asciidoc/howto/jersey.adoc | 4 +- .../src/docs/asciidoc/howto/logging.adoc | 14 +-- .../src/docs/asciidoc/howto/messaging.adoc | 2 +- .../howto/properties-and-configuration.adoc | 30 +++--- .../src/docs/asciidoc/howto/security.adoc | 4 +- .../src/docs/asciidoc/howto/spring-mvc.adoc | 8 +- .../docs/asciidoc/howto/testcontainers.adoc | 4 +- .../howto/testing-with-spring-security.adoc | 2 +- .../howto/traditional-deployment.adoc | 20 ++-- .../src/docs/asciidoc/howto/webserver.adoc | 38 +++---- .../asciidoc/using/auto-configuration.adoc | 2 +- .../docs/asciidoc/using/build-systems.adoc | 4 +- .../src/docs/asciidoc/using/devtools.adoc | 22 ++--- .../using/running-your-application.adoc | 12 +-- ...spring-beans-and-dependency-injection.adoc | 4 +- .../asciidoc/using/structuring-your-code.adoc | 2 +- ...-the-springbootapplication-annotation.adoc | 4 +- 72 files changed, 588 insertions(+), 588 deletions(-) diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/cloud-foundry.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/cloud-foundry.adoc index 0be451b9a7..4de1190a34 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/cloud-foundry.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/cloud-foundry.adoc @@ -17,7 +17,7 @@ If you want to fully disable the `/cloudfoundryapplication` endpoints, you can a .application.properties -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- management: cloudfoundry: @@ -32,7 +32,7 @@ By default, the security verification for `/cloudfoundryapplication` endpoints m If your Cloud Foundry UAA or Cloud Controller services use self-signed certificates, you need to set the following property: .application.properties -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- management: cloudfoundry: @@ -50,7 +50,7 @@ If you expect the Cloud Foundry endpoints to always be available at `/cloudfound The configuration will differ depending on the web server in use. For Tomcat, the following configuration can be added: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/actuator/cloudfoundry/customcontextpath/MyCloudFoundryConfiguration.java[] ---- diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/enabling.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/enabling.adoc index 2e8db6f5d8..a962b0ce45 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/enabling.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/enabling.adoc @@ -11,7 +11,7 @@ Actuators can generate a large amount of motion from a small change. To add the actuator to a Maven based project, add the following '`Starter`' dependency: -[source,xml,indent=0] +[source,xml,indent=0,subs="verbatim"] ---- @@ -23,7 +23,7 @@ To add the actuator to a Maven based project, add the following '`Starter`' depe For Gradle, use the following declaration: -[source,gradle,indent=0] +[source,gradle,indent=0,subs="verbatim"] ---- dependencies { implementation 'org.springframework.boot:spring-boot-starter-actuator' diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/endpoints.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/endpoints.adoc index 87c55537f0..165c5352de 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/endpoints.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/endpoints.adoc @@ -120,7 +120,7 @@ By default, all endpoints except for `shutdown` are enabled. To configure the enablement of an endpoint, use its `management.endpoint..enabled` property. The following example enables the `shutdown` endpoint: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- management: endpoint: @@ -131,7 +131,7 @@ The following example enables the `shutdown` endpoint: If you prefer endpoint enablement to be opt-in rather than opt-out, set the configprop:management.endpoints.enabled-by-default[] property to `false` and use individual endpoint `enabled` properties to opt back in. The following example enables the `info` endpoint and disables all other endpoints: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- management: endpoints: @@ -282,7 +282,7 @@ Both `include` and `exclude` properties can be configured with a list of endpoin For example, to stop exposing all endpoints over JMX and only expose the `health` and `info` endpoints, use the following property: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- management: endpoints: @@ -294,7 +294,7 @@ For example, to stop exposing all endpoints over JMX and only expose the `health `*` can be used to select all endpoints. For example, to expose everything over HTTP except the `env` and `beans` endpoints, use the following properties: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- management: endpoints: @@ -320,7 +320,7 @@ If you wish to configure custom security for HTTP endpoints, for example, only a A typical Spring Security configuration might look something like the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/actuator/endpoints/security/typical/MySecurityConfiguration.java[] ---- @@ -332,7 +332,7 @@ See the API documentation ({spring-boot-actuator-restapi-docs}[HTML] or {spring- If you deploy applications behind a firewall, you may prefer that all your actuator endpoints can be accessed without requiring authentication. You can do so by changing the configprop:management.endpoints.web.exposure.include[] property, as follows: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- management: endpoints: @@ -343,7 +343,7 @@ You can do so by changing the configprop:management.endpoints.web.exposure.inclu Additionally, if Spring Security is present, you would need to add custom security configuration that allows unauthenticated access to the endpoints as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/actuator/endpoints/security/exposeall/MySecurityConfiguration.java[] ---- @@ -359,7 +359,7 @@ Endpoints automatically cache responses to read operations that do not take any To configure the amount of time for which an endpoint will cache a response, use its `cache.time-to-live` property. The following example sets the time-to-live of the `beans` endpoint's cache to 10 seconds: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- management: endpoint: @@ -379,7 +379,7 @@ The "`discovery page`" is available on `/actuator` by default. To disable the "`discovery page`", add the following property to your application properties: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- management: endpoints: @@ -402,7 +402,7 @@ If you use Spring MVC or Spring WebFlux, Actuator's web endpoints can be configu CORS support is disabled by default and is only enabled once the configprop:management.endpoints.web.cors.allowed-origins[] property has been set. The following configuration permits `GET` and `POST` calls from the `example.com` domain: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- management: endpoints: @@ -424,7 +424,7 @@ If both Jersey and Spring MVC are available, Spring MVC will be used. The following example exposes a read operation that returns a custom object: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/actuator/endpoints/implementingcustom/MyEndpoint.java[tag=read] ---- @@ -451,7 +451,7 @@ They can be made optional by annotating them with either `@javax.annotation.Null Each root property in the JSON request body can be mapped to a parameter of the endpoint. Consider the following JSON request body: -[source,json,indent=0] +[source,json,indent=0,subs="verbatim"] ---- { "name": "test", @@ -461,7 +461,7 @@ Consider the following JSON request body: This can be used to invoke a write operation that takes `String name` and `int counter` parameters, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/actuator/endpoints/implementingcustom/MyEndpoint.java[tag=write] ---- @@ -740,7 +740,7 @@ You need to provide an implementation of the `health()` method and return a `Hea The `Health` response should include a status and can optionally include additional details to be displayed. The following code shows a sample `HealthIndicator` implementation: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/actuator/endpoints/health/writingcustomhealthindicators/MyHealthIndicator.java[] ---- @@ -754,7 +754,7 @@ In such cases, a custom implementation of the {spring-boot-actuator-module-code} For example, assume a new `Status` with code `FATAL` is being used in one of your `HealthIndicator` implementations. To configure the severity order, add the following property to your application properties: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- management: endpoint: @@ -771,7 +771,7 @@ Configuring a custom mapping disables the defaults mappings for `DOWN` and `OUT_ If you want to retain the default mappings they must be configured explicitly alongside any custom mappings. For example, the following property maps `FATAL` to 503 (service unavailable) and retains the default mappings for `DOWN` and `OUT_OF_SERVICE`: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- management: endpoint: @@ -818,7 +818,7 @@ If you need to register a regular `HealthContributor`, you should wrap it using To provide custom health information from a reactive API, you can register Spring beans that implement the {spring-boot-actuator-module-code}/health/ReactiveHealthIndicator.java[`ReactiveHealthIndicator`] interface. The following code shows a sample `ReactiveHealthIndicator` implementation: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/actuator/endpoints/health/reactivehealthindicators/MyReactiveHealthIndicator.java[] ---- @@ -872,7 +872,7 @@ It's sometimes useful to organize health indicators into groups that can be used To create a health indicator group you can use the `management.endpoint.health.group.` property and specify a list of health indicator IDs to `include` or `exclude`. For example, to create a group that includes only database indicators you can define the following: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- management: endpoint: @@ -886,7 +886,7 @@ You can then check the result by hitting `http://localhost:8080/actuator/health/ Similarly, to create a group that excludes the database indicators from the group and includes all the other indicators, you can define the following: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- management: endpoint: @@ -899,7 +899,7 @@ Similarly, to create a group that excludes the database indicators from the grou By default groups will inherit the same `StatusAggregator` and `HttpCodeStatusMapper` settings as the system health, however, these can also be defined on a per-group basis. It's also possible to override the `show-details` and `roles` properties if required: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- management: endpoint: @@ -940,7 +940,7 @@ They will also be exposed as separate HTTP Probes using <> are available for them. You can, for example, configure additional Health Indicators: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- management: endpoint: @@ -1108,7 +1108,7 @@ You can customize the data exposed by the `info` endpoint by setting `+info.*+` All `Environment` properties under the `info` key are automatically exposed. For example, you could add the following settings to your `application.properties` file: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- info: app: @@ -1124,7 +1124,7 @@ Rather than hardcoding those values, you could also < org.jolokia @@ -75,7 +75,7 @@ Jolokia has a number of settings that you would traditionally configure by setti With Spring Boot, you can use your `application.properties` file. To do so, prefix the parameter with `management.endpoint.jolokia.config.`, as shown in the following example: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- management: endpoint: @@ -90,7 +90,7 @@ To do so, prefix the parameter with `management.endpoint.jolokia.config.`, as sh ==== Disabling Jolokia If you use Jolokia but do not want Spring Boot to configure it, set the configprop:management.endpoint.jolokia.enabled[] property to `false`, as follows: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- management: endpoint: diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/loggers.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/loggers.adoc index 74e320c669..8ada3ab66d 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/loggers.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/loggers.adoc @@ -21,7 +21,7 @@ These levels can be one of: === Configure a Logger To configure a given logger, `POST` a partial entity to the resource's URI, as shown in the following example: -[source,json,indent=0] +[source,json,indent=0,subs="verbatim"] ---- { "configuredLevel": "DEBUG" diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/metrics.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/metrics.adoc index bee33574b5..bd4b0bf210 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/metrics.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/metrics.adoc @@ -34,7 +34,7 @@ Most registries share common features. For instance, you can disable a particular registry even if the Micrometer registry implementation is on the classpath. For example, to disable Datadog: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- management: metrics: @@ -45,7 +45,7 @@ For example, to disable Datadog: You can also disable all registries unless stated otherwise by the registry-specific property, as shown in the following example: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- management: metrics: @@ -56,7 +56,7 @@ You can also disable all registries unless stated otherwise by the registry-spec Spring Boot will also add any auto-configured registries to the global static composite registry on the `Metrics` class unless you explicitly tell it not to: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- management: metrics: @@ -65,14 +65,14 @@ Spring Boot will also add any auto-configured registries to the global static co You can register any number of `MeterRegistryCustomizer` beans to further configure the registry, such as applying common tags, before any meters are registered with the registry: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/actuator/metrics/gettingstarted/commontags/MyMeterRegistryConfiguration.java ---- You can apply customizations to particular registry implementations by being more specific about the generic type: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/actuator/metrics/gettingstarted/specifictype/MyMeterRegistryConfiguration.java ---- @@ -91,7 +91,7 @@ Spring Boot also < io.prometheus @@ -406,7 +406,7 @@ For advanced configuration, you can also provide your own `PrometheusPushGateway SignalFx registry pushes metrics to {micrometer-registry-docs}/signalFx[SignalFx] periodically. To export metrics to https://www.signalfx.com[SignalFx], your access token must be provided: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- management: metrics: @@ -417,7 +417,7 @@ To export metrics to https://www.signalfx.com[SignalFx], your access token must You can also change the interval at which metrics are sent to SignalFx: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- management: metrics: @@ -436,7 +436,7 @@ This allows you to see what metrics are collected in the < ---- @@ -75,7 +75,7 @@ The following nested elements can be used with the task: This section shows two examples of Ant tasks. .Specify +start-class+ -[source,xml,indent=0] +[source,xml,indent=0,subs="verbatim"] ---- @@ -89,7 +89,7 @@ This section shows two examples of Ant tasks. ---- .Detect +start-class+ -[source,xml,indent=0] +[source,xml,indent=0,subs="verbatim"] ---- @@ -130,19 +130,19 @@ The following attributes are supported: This section contains three examples of using `findmainclass`. .Find and log -[source,xml,indent=0] +[source,xml,indent=0,subs="verbatim"] ---- ---- .Find and set -[source,xml,indent=0] +[source,xml,indent=0,subs="verbatim"] ---- ---- .Override and set -[source,xml,indent=0] +[source,xml,indent=0,subs="verbatim"] ---- ---- diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/build-tool-plugins/other-build-systems.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/build-tool-plugins/other-build-systems.adoc index 549dad9b86..7c5d6a360b 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/build-tool-plugins/other-build-systems.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/build-tool-plugins/other-build-systems.adoc @@ -37,7 +37,7 @@ An exception is thrown if more than one candidate is found. === Example Repackage Implementation The following example shows a typical repackage implementation: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/buildtoolplugins/otherbuildsystems/examplerepackageimplementation/MyBuildTool.java[] ---- diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/cli/groovy-beans-dsl.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/cli/groovy-beans-dsl.adoc index 336aa513b6..4afc812161 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/cli/groovy-beans-dsl.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/cli/groovy-beans-dsl.adoc @@ -3,7 +3,7 @@ Spring Framework 4.0 has native support for a `beans{}` "`DSL`" (borrowed from https://grails.org/[Grails]), and you can embed bean definitions in your Groovy application scripts by using the same format. This is sometimes a good way to include external features like middleware declarations, as shown in the following example: -[source,groovy,indent=0] +[source,groovy,indent=0,subs="verbatim"] ---- @Configuration(proxyBeanMethods = false) class Application implements CommandLineRunner { diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/cli/using-the-cli.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/cli/using-the-cli.adoc index 5f98b07f1c..e8789a3cde 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/cli/using-the-cli.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/cli/using-the-cli.adoc @@ -3,7 +3,7 @@ Once you have installed the CLI, you can run it by typing `spring` and pressing Enter at the command line. If you run `spring` without any arguments, a help screen is displayed, as follows: -[indent=0,subs="verbatim,quotes,attributes"] +[indent=0,subs="verbatim"] ---- $ spring usage: spring [--help] [--version] @@ -41,7 +41,7 @@ You can type `spring help` to get more details about any of the supported comman The `version` command provides a quick way to check which version of Spring Boot you are using, as follows: -[indent=0,subs="verbatim,quotes,attributes"] +[indent=0,subs="verbatim,attributes"] ---- $ spring version Spring CLI v{spring-boot-version} @@ -57,28 +57,28 @@ The Spring Boot CLI is completely self-contained, so you do not need any externa The following example shows a "`hello world`" web application written in Groovy: .hello.groovy -[source,groovy,indent=0,subs="verbatim,quotes,attributes"] +[source,groovy,indent=0,subs="verbatim"] ---- include::{docs-groovy}/cli/usingthecli/run/WebApplication.groovy[tag=*] ---- To compile and run the application, type the following command: -[indent=0,subs="verbatim,quotes,attributes"] +[indent=0,subs="verbatim"] ---- $ spring run hello.groovy ---- To pass command-line arguments to the application, use `--` to separate the commands from the "`spring`" command arguments, as shown in the following example: -[indent=0,subs="verbatim,quotes,attributes"] +[indent=0,subs="verbatim"] ---- $ spring run hello.groovy -- --server.port=9000 ---- To set JVM command line arguments, you can use the `JAVA_OPTS` environment variable, as shown in the following example: -[indent=0,subs="verbatim,quotes,attributes"] +[indent=0,subs="verbatim"] ---- $ JAVA_OPTS=-Xmx1024m spring run hello.groovy ---- @@ -175,7 +175,7 @@ The annotation's value should specify the coordinates (`groupId:artifactId:versi For example, consider the following declaration: -[source,groovy,indent=0] +[source,groovy,indent=0,subs="verbatim"] ---- include::{docs-groovy}/cli/usingthecli/run/customdependencymanagement/single/CustomDependencyManagement.groovy[tag=*] ---- @@ -184,7 +184,7 @@ The preceding declaration picks up `custom-bom-1.0.0.pom` in a Maven repository When you specify multiple BOMs, they are applied in the order in which you declare them, as shown in the following example: -[source,groovy,indent=0] +[source,groovy,indent=0,subs="verbatim"] ---- include::{docs-groovy}/cli/usingthecli/run/customdependencymanagement/multiple/CustomDependencyManagement.groovy[tag=*] ---- @@ -305,7 +305,7 @@ If you do not use either of these shells (perhaps you are a Windows user), you c From inside the embedded shell, you can run other commands directly: -[indent=0,subs="verbatim,quotes,attributes"] +[indent=0,subs="verbatim,attributes"] ---- $ version Spring CLI v{spring-boot-version} @@ -322,7 +322,7 @@ To exit the embedded shell, press `ctrl-c`. You can add extensions to the CLI by using the `install` command. The command takes one or more sets of artifact coordinates in the format `group:artifact:version`, as shown in the following example: -[indent=0,subs="verbatim,quotes,attributes"] +[indent=0,subs="verbatim"] ---- $ spring install com.example:spring-boot-cli-extension:1.0.0.RELEASE ---- @@ -332,7 +332,7 @@ In addition to installing the artifacts identified by the coordinates you supply To uninstall a dependency, use the `uninstall` command. As with the `install` command, it takes one or more sets of artifact coordinates in the format of `group:artifact:version`, as shown in the following example: -[indent=0,subs="verbatim,quotes,attributes"] +[indent=0,subs="verbatim"] ---- $ spring uninstall com.example:spring-boot-cli-extension:1.0.0.RELEASE ---- @@ -341,7 +341,7 @@ It uninstalls the artifacts identified by the coordinates you supply and their d To uninstall all additional dependencies, you can use the `--all` option, as shown in the following example: -[indent=0,subs="verbatim,quotes,attributes"] +[indent=0,subs="verbatim"] ---- $ spring uninstall --all ---- diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/configuration-metadata/annotation-processor.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/configuration-metadata/annotation-processor.adoc index 225b85f543..5f5e521523 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/configuration-metadata/annotation-processor.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/configuration-metadata/annotation-processor.adoc @@ -11,7 +11,7 @@ To use the processor, include a dependency on `spring-boot-configuration-process With Maven the dependency should be declared as optional, as shown in the following example: -[source,xml,indent=0,subs="verbatim,quotes,attributes"] +[source,xml,indent=0,subs="verbatim"] ---- org.springframework.boot @@ -22,7 +22,7 @@ With Maven the dependency should be declared as optional, as shown in the follow With Gradle, the dependency should be declared in the `annotationProcessor` configuration, as shown in the following example: -[source,gradle,indent=0,subs="verbatim,quotes,attributes"] +[source,gradle,indent=0,subs="verbatim"] ---- dependencies { annotationProcessor "org.springframework.boot:spring-boot-configuration-processor" @@ -31,7 +31,7 @@ With Gradle, the dependency should be declared in the `annotationProcessor` conf If you are using an `additional-spring-configuration-metadata.json` file, the `compileJava` task should be configured to depend on the `processResources` task, as shown in the following example: -[source,gradle,indent=0,subs="verbatim,quotes,attributes"] +[source,gradle,indent=0,subs="verbatim"] ---- compileJava.inputs.files(processResources) ---- @@ -45,7 +45,7 @@ There are several ways to do this. With Maven, you can configure the `maven-apt-plugin` explicitly and add the dependency to the annotation processor only there. You could also let the AspectJ plugin run all the processing and disable annotation processing in the `maven-compiler-plugin` configuration, as follows: -[source,xml,indent=0,subs="verbatim,quotes,attributes"] +[source,xml,indent=0,subs="verbatim"] ---- org.apache.maven.plugins @@ -69,7 +69,7 @@ The annotation processor also supports the use of the `@Data`, `@Getter`, and `@ Consider the following example: -[source,java,indent=0,subs="verbatim,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/configurationmetadata/annotationprocessor/automaticmetadatageneration/MyServerProperties.java[] ---- @@ -86,14 +86,14 @@ Also, the annotation processor cannot auto-detect default values for ``Enum``s a For cases where the default value could not be detected, <> should be provided. Consider the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/configurationmetadata/annotationprocessor/automaticmetadatageneration/MyMessagingProperties.java[] ---- In order to document default values for properties in the class above, you could add the following content to <>: -[source,json,indent=0] +[source,json,indent=0,subs="verbatim"] ---- {"properties": [ { @@ -117,7 +117,7 @@ The annotation processor automatically considers inner classes as nested propert Rather than documenting the `ip` and `port` at the root of the namespace, we could create a sub-namespace for it. Consider the updated example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/configurationmetadata/annotationprocessor/automaticmetadatageneration/nestedproperties/MyServerProperties.java[] ---- diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/configuration-metadata/format.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/configuration-metadata/format.adoc index d9298d3b02..f7d7825d43 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/configuration-metadata/format.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/configuration-metadata/format.adoc @@ -3,7 +3,7 @@ Configuration metadata files are located inside jars under `META-INF/spring-configuration-metadata.json`. They use a JSON format with items categorized under either "`groups`" or "`properties`" and additional values hints categorized under "hints", as shown in the following example: -[source,json,indent=0] +[source,json,indent=0,subs="verbatim"] ---- {"groups": [ { @@ -68,7 +68,7 @@ They use a JSON format with items categorized under either "`groups`" or "`prope Each "`property`" is a configuration item that the user specifies with a given value. For example, `server.port` and `server.address` might be specified in `application.properties`, as follows: -[source,properties,indent=0,configprops] +[source,properties,indent=0,subs="verbatim",configprops] ---- server.port=9090 server.address=127.0.0.1 @@ -207,7 +207,7 @@ Deprecation can also be specified declaratively in code by adding the `@Deprecat For instance, assume that the `my.app.target` property was confusing and was renamed to `my.app.name`. The following example shows how to handle that situation: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/configurationmetadata/format/group/MyProperties.java[] ---- diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/configuration-metadata/manual-hints.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/configuration-metadata/manual-hints.adoc index 662c64ffa5..4df1946045 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/configuration-metadata/manual-hints.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/configuration-metadata/manual-hints.adoc @@ -18,7 +18,7 @@ The special `.keys` and `.values` suffixes must refer to the keys and the values Assume a `my.contexts` maps magic `String` values to an integer, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/configurationmetadata/manualhints/valuehint/MyProperties.java[] ---- @@ -26,7 +26,7 @@ include::{docs-java}/configurationmetadata/manualhints/valuehint/MyProperties.ja The magic values are (in this example) are `sample1` and `sample2`. In order to offer additional content assistance for the keys, you could add the following JSON to <>: -[source,json,indent=0] +[source,json,indent=0,subs="verbatim"] ---- {"hints": [ { @@ -101,7 +101,7 @@ This provider is typically used if you have a list of values and any extra value The following example offers `on` and `off` as auto-completion values for `system.state`: -[source,json,indent=0] +[source,json,indent=0,subs="verbatim"] ---- {"hints": [ { @@ -152,7 +152,7 @@ This provider supports the following parameters: The following metadata snippet corresponds to the standard `server.servlet.jsp.class-name` property that defines the `JspServlet` class name to use: -[source,json,indent=0] +[source,json,indent=0,subs="verbatim"] ---- {"hints": [ { @@ -202,7 +202,7 @@ TIP: If multiple values can be provided, use a `Collection` or _Array_ type to t The following metadata snippet corresponds to the standard `spring.liquibase.change-log` property that defines the path to the changelog to use. It is actually used internally as a `org.springframework.core.io.Resource` but cannot be exposed as such, because we need to keep the original String value to pass it to the Liquibase API. -[source,json,indent=0] +[source,json,indent=0,subs="verbatim"] ---- {"hints": [ { @@ -246,7 +246,7 @@ The following metadata snippet corresponds to the standard `logging.level` prope Keys are _logger names_, and values correspond to the standard log levels or any custom level. As Spring Boot defines a few logger groups out-of-the-box, dedicated value hints have been added for those. -[source,json,indent=0] +[source,json,indent=0,subs="verbatim"] ---- {"hints": [ { @@ -326,7 +326,7 @@ This provider supports the following parameters: The following metadata snippet corresponds to the standard `spring.jmx.server` property that defines the name of the `MBeanServer` bean to use: -[source,json,indent=0] +[source,json,indent=0,subs="verbatim"] ---- {"hints": [ { @@ -354,7 +354,7 @@ The **spring-profile-name** provider auto-completes the Spring profiles that are The following metadata snippet corresponds to the standard `spring.profiles.active` property that defines the name of the Spring profile(s) to enable: -[source,json,indent=0] +[source,json,indent=0,subs="verbatim"] ---- {"hints": [ { diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/deployment/cloud.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/deployment/cloud.adoc index 9ce50ac99d..4920eb083d 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/deployment/cloud.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/deployment/cloud.adoc @@ -27,7 +27,7 @@ Once you have built your application (by using, for example, `mvn clean package` Be sure to have https://docs.cloudfoundry.org/cf-cli/getting-started.html#login[logged in with your `cf` command line client] before pushing an application. The following line shows using the `cf push` command to deploy an application: -[indent=0,subs="verbatim,quotes,attributes"] +[indent=0,subs="verbatim"] ---- $ cf push acloudyspringtime -p target/demo-0.0.1-SNAPSHOT.jar ---- @@ -39,7 +39,7 @@ If there is a Cloud Foundry https://docs.cloudfoundry.org/devguide/deploy-apps/m At this point, `cf` starts uploading your application, producing output similar to the following example: -[indent=0,subs="verbatim,quotes,attributes"] +[indent=0,subs="verbatim,quotes"] ---- Uploading acloudyspringtime... *OK* Preparing to start acloudyspringtime... *OK* @@ -68,7 +68,7 @@ Congratulations! The application is now live! Once your application is live, you can verify the status of the deployed application by using the `cf apps` command, as shown in the following example: -[indent=0,subs="verbatim,quotes,attributes"] +[indent=0,subs="verbatim"] ---- $ cf apps Getting applications in ... @@ -93,7 +93,7 @@ Process-scoped environment variables are language agnostic. Environment variables do not always make for the easiest API, so Spring Boot automatically extracts them and flattens the data into properties that can be accessed through Spring's `Environment` abstraction, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/deployment/cloud/cloudfoundry/bindingtoservices/MyBean.java[] ---- @@ -124,7 +124,7 @@ You can configure a sleep execution in a preStop handler to avoid requests being This sleep should be long enough for new requests to stop being routed to the pod and its duration will vary from deployment to deployment. The preStop handler can be configured via the PodSpec in the pod's configuration file as follows: -[source,yml,indent=0] +[source,yml,indent=0,subs="verbatim"] ---- spec: containers: @@ -161,7 +161,7 @@ The `$PORT` environment variable is assigned to us by the Heroku PaaS. This should be everything you need. The most common deployment workflow for Heroku deployments is to `git push` the code to production, as shown in the following example: -[indent=0,subs="verbatim,quotes,attributes"] +[indent=0,subs="verbatim,quotes"] ---- $ git push heroku main @@ -270,7 +270,7 @@ By default, Elastic Beanstalk uploads sources and compiles them in AWS. However, it is best to upload the binaries instead. To do so, add lines similar to the following to your `.elasticbeanstalk/config.yml` file: -[source,xml,indent=0,subs="verbatim,quotes,attributes"] +[source,xml,indent=0,subs="verbatim"] ---- deploy: artifact: target/demo-0.0.1-SNAPSHOT.jar @@ -321,7 +321,7 @@ If your executable jar or war contains an https://boxfuse.com/docs/payloads/spri At this point, `boxfuse` creates an image for your application, uploads it, and configures and starts the necessary resources on AWS, resulting in output similar to the following example: -[indent=0,subs="verbatim,quotes,attributes"] +[indent=0,subs="verbatim"] ---- Fusing Image for myapp-1.0.jar ... Image fused in 00:06.838s (53937 K) -> axelfontaine/myapp:1.0 @@ -362,7 +362,7 @@ Follow https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/appe Alternatively, App Engine Flex requires you to create an `app.yaml` file to describe the resources your app requires. Normally, you put this file in `src/main/appengine`, and it should resemble the following file: -[source,yaml,indent=0] +[source,yaml,indent=0,subs="verbatim"] ---- service: default @@ -388,7 +388,7 @@ Normally, you put this file in `src/main/appengine`, and it should resemble the You can deploy the app (for example, with a Maven plugin) by adding the project ID to the build configuration, as shown in the following example: -[source,xml,indent=0,subs="verbatim,quotes,attributes"] +[source,xml,indent=0,subs="verbatim"] ---- com.google.cloud.tools diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/deployment/installing.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/deployment/installing.adoc index beef625c3c..5ef2fa9aad 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/deployment/installing.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/deployment/installing.adoc @@ -15,7 +15,7 @@ A standard-format jar file that contains one or more zip64-format nested jars ca To create a '`fully executable`' jar with Maven, use the following plugin configuration: -[source,xml,indent=0,subs="verbatim,quotes,attributes"] +[source,xml,indent=0,subs="verbatim"] ---- org.springframework.boot @@ -28,7 +28,7 @@ To create a '`fully executable`' jar with Maven, use the following plugin config The following example shows the equivalent Gradle configuration: -[source,gradle,indent=0,subs="verbatim,quotes,attributes"] +[source,gradle,indent=0,subs="verbatim"] ---- bootJar { launchScript() @@ -66,7 +66,7 @@ The script supports the following features: Assuming that you have a Spring Boot application installed in `/var/myapp`, to install a Spring Boot application as an `init.d` service, create a symlink, as follows: -[indent=0,subs="verbatim,quotes,attributes"] +[indent=0,subs="verbatim"] ---- $ sudo ln -s /var/myapp/myapp.jar /etc/init.d/myapp ---- @@ -74,7 +74,7 @@ Assuming that you have a Spring Boot application installed in `/var/myapp`, to i Once installed, you can start and stop the service in the usual way. For example, on a Debian-based system, you could start it with the following command: -[indent=0,subs="verbatim,quotes,attributes"] +[indent=0,subs="verbatim"] ---- $ service myapp start ---- @@ -84,7 +84,7 @@ TIP: If your application fails to start, check the log file written to `/var/log You can also flag the application to start automatically by using your standard operating system tools. For example, on Debian, you could use the following command: -[indent=0,subs="verbatim,quotes,attributes"] +[indent=0,subs="verbatim"] ---- $ update-rc.d myapp defaults ---- @@ -101,7 +101,7 @@ When the environment variable is not set, the user who owns the jar file is used You should never run a Spring Boot application as `root`, so `RUN_AS_USER` should never be root and your application's jar file should never be owned by root. Instead, create a specific user to run your application and set the `RUN_AS_USER` environment variable or use `chown` to make it the owner of the jar file, as shown in the following example: -[indent=0,subs="verbatim,quotes,attributes"] +[indent=0,subs="verbatim"] ---- $ chown bootapp:bootapp your-app.jar ---- @@ -114,7 +114,7 @@ For example, you can set the account's shell to `/usr/sbin/nologin`. You should also take steps to prevent the modification of your application's jar file. Firstly, configure its permissions so that it cannot be written and can only be read or executed by its owner, as shown in the following example: -[indent=0,subs="verbatim,quotes,attributes"] +[indent=0,subs="verbatim"] ---- $ chmod 500 your-app.jar ---- @@ -123,7 +123,7 @@ Second, you should also take steps to limit the damage if your application or th If an attacker does gain access, they could make the jar file writable and change its contents. One way to protect against this is to make it immutable by using `chattr`, as shown in the following example: -[indent=0,subs="verbatim,quotes,attributes"] +[indent=0,subs="verbatim"] ---- $ sudo chattr +i your-app.jar ---- @@ -134,7 +134,7 @@ If root is used to control the application's service and you < org.springframework.boot @@ -293,7 +293,7 @@ It is recommended to add the following dependency in a module that contains auto If you have defined auto-configurations directly in your application, make sure to configure the `spring-boot-maven-plugin` to prevent the `repackage` goal from adding the dependency into the fat jar: -[source,xml,indent=0,subs="verbatim,quotes,attributes"] +[source,xml,indent=0,subs="verbatim"] ---- @@ -317,7 +317,7 @@ If you have defined auto-configurations directly in your application, make sure With Gradle 4.5 and earlier, the dependency should be declared in the `compileOnly` configuration, as shown in the following example: -[source,gradle,indent=0,subs="verbatim,quotes,attributes"] +[source,gradle,indent=0,subs="verbatim"] ---- dependencies { compileOnly "org.springframework.boot:spring-boot-autoconfigure-processor" @@ -326,7 +326,7 @@ With Gradle 4.5 and earlier, the dependency should be declared in the `compileOn With Gradle 4.6 and later, the dependency should be declared in the `annotationProcessor` configuration, as shown in the following example: -[source,gradle,indent=0,subs="verbatim,quotes,attributes"] +[source,gradle,indent=0,subs="verbatim"] ---- dependencies { annotationProcessor "org.springframework.boot:spring-boot-autoconfigure-processor" diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/developing-web-applications.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/developing-web-applications.adoc index aecb06feb7..818f79c3d5 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/developing-web-applications.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/developing-web-applications.adoc @@ -17,7 +17,7 @@ Methods in your controller are mapped to HTTP by using `@RequestMapping` annotat The following code shows a typical `@RestController` that serves JSON data: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/developingwebapplications/springmvc/MyRestController.java[] ---- @@ -67,7 +67,7 @@ By default, strings are encoded in `UTF-8`. If you need to add or customize converters, you can use Spring Boot's `HttpMessageConverters` class, as shown in the following listing: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/developingwebapplications/springmvc/messageconverters/MyHttpMessageConvertersConfiguration.java[] ---- @@ -85,7 +85,7 @@ Custom serializers are usually https://github.com/FasterXML/jackson-docs/wiki/Ja You can use the `@JsonComponent` annotation directly on `JsonSerializer`, `JsonDeserializer` or `KeyDeserializer` implementations. You can also use it on classes that contain serializers/deserializers as inner classes, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/developingwebapplications/springmvc/json/MyJsonComponent.java[] ---- @@ -98,7 +98,7 @@ See {spring-boot-module-api}/jackson/JsonObjectSerializer.html[`JsonObjectSerial The example above can be rewritten to use `JsonObjectSerializer`/`JsonObjectDeserializer` as follows: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/developingwebapplications/springmvc/json/object/MyJsonComponent.java[] ---- @@ -123,7 +123,7 @@ Most of the time, this does not happen (unless you modify the default MVC config By default, resources are mapped on `+/**+`, but you can tune that with the configprop:spring.mvc.static-path-pattern[] property. For instance, relocating all resources to `/resources/**` can be achieved as follows: -[source,yaml,indent=0,subs="verbatim,quotes,attributes",configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: mvc: @@ -150,7 +150,7 @@ Otherwise, all Webjars resolve as a `404`. To use cache busting, the following configuration configures a cache busting solution for all static resources, effectively adding a content hash, such as ``, in URLs: -[source,yaml,indent=0,subs="verbatim,quotes,attributes",configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: web: @@ -170,7 +170,7 @@ When loading resources dynamically with, for example, a JavaScript module loader That is why other strategies are also supported and can be combined. A "fixed" strategy adds a static version string in the URL without changing the file name, as shown in the following example: -[source,yaml,indent=0,subs="verbatim,quotes,attributes",configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: web: @@ -218,7 +218,7 @@ Nowadays, Content Negotiation is much more reliable. There are other ways to deal with HTTP clients that don't consistently send proper "Accept" request headers. Instead of using suffix matching, we can use a query parameter to ensure that requests like `"GET /projects/spring-boot?format=json"` will be mapped to `@GetMapping("/projects/spring-boot")`: -[source,yaml,indent=0,subs="verbatim,quotes,attributes",configblocks] +[source,yaml,indent=0,subs="verbatim",configblocks] ---- spring: mvc: @@ -228,7 +228,7 @@ Instead of using suffix matching, we can use a query parameter to ensure that re Or if you prefer to use a different parameter name: -[source,properties,indent=0,subs="verbatim,quotes,attributes"] +[source,properties,indent=0,subs="verbatim"] ---- spring: mvc: @@ -239,7 +239,7 @@ Or if you prefer to use a different parameter name: Most standard media types are supported out-of-the-box, but you can also define new ones: -[source,yaml,indent=0,subs="verbatim,quotes,attributes",configblocks] +[source,yaml,indent=0,subs="verbatim",configblocks] ---- spring: mvc: @@ -253,7 +253,7 @@ Most standard media types are supported out-of-the-box, but you can also define Suffix pattern matching is deprecated and will be removed in a future release. If you understand the caveats and would still like your application to use suffix pattern matching, the following configuration is required: -[source,yaml,indent=0,subs="verbatim,quotes,attributes",configblocks] +[source,yaml,indent=0,subs="verbatim",configblocks] ---- spring: mvc: @@ -265,7 +265,7 @@ If you understand the caveats and would still like your application to use suffi Alternatively, rather than open all suffix patterns, it's more secure to only support registered suffix patterns: -[source,yaml,indent=0,subs="verbatim,quotes,attributes",configblocks] +[source,yaml,indent=0,subs="verbatim",configblocks] ---- spring: mvc: @@ -279,7 +279,7 @@ As of Spring Framework 5.3, Spring MVC supports several implementation strategie It was previously only supporting the `AntPathMatcher` strategy, but it now also offers `PathPatternParser`. Spring Boot now provides a configuration property to choose and opt in the new strategy: -[source,yaml,indent=0,subs="verbatim,quotes,attributes",configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: mvc: @@ -347,7 +347,7 @@ To do so, extend `BasicErrorController`, add a public method with a `@RequestMap You can also define a class annotated with `@ControllerAdvice` to customize the JSON document to return for a particular controller and/or exception type, as shown in the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/developingwebapplications/springmvc/errorhandling/MyControllerAdvice.java[] ---- @@ -357,7 +357,7 @@ In the preceding example, if `YourException` is thrown by a controller defined i In some cases, errors handled at the controller level are not recorded by the <>. Applications can ensure that such exceptions are recorded with the request metrics by setting the handled exception as a request attribute: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/developingwebapplications/springmvc/errorhandling/MyController.java[] ---- @@ -372,7 +372,7 @@ The name of the file should be the exact status code or a series mask. For example, to map `404` to a static HTML file, your directory structure would be as follows: -[source,indent=0,subs="verbatim,quotes,attributes"] +[source,indent=0,subs="verbatim"] ---- src/ +- main/ @@ -387,7 +387,7 @@ For example, to map `404` to a static HTML file, your directory structure would To map all `5xx` errors by using a FreeMarker template, your directory structure would be as follows: -[source,indent=0,subs="verbatim,quotes,attributes"] +[source,indent=0,subs="verbatim"] ---- src/ +- main/ @@ -402,7 +402,7 @@ To map all `5xx` errors by using a FreeMarker template, your directory structure For more complex mappings, you can also add beans that implement the `ErrorViewResolver` interface, as shown in the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/developingwebapplications/springmvc/errorhandling/errorpages/MyErrorViewResolver.java[] ---- @@ -417,14 +417,14 @@ The `ErrorController` then picks up any unhandled exceptions. For applications that do not use Spring MVC, you can use the `ErrorPageRegistrar` interface to directly register `ErrorPages`. This abstraction works directly with the underlying embedded servlet container and works even if you do not have a Spring MVC `DispatcherServlet`. -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/developingwebapplications/springmvc/errorhandling/errorpageswithoutspringmvc/MyErrorPagesConfiguration.java[] ---- NOTE: If you register an `ErrorPage` with a path that ends up being handled by a `Filter` (as is common with some non-Spring web frameworks, like Jersey and Wicket), then the `Filter` has to be explicitly registered as an `ERROR` dispatcher, as shown in the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/developingwebapplications/springmvc/errorhandling/errorpageswithoutspringmvc/MyFilterConfiguration.java[] ---- @@ -467,7 +467,7 @@ As of version 4.2, Spring MVC {spring-framework-docs}/web.html#mvc-cors[supports Using {spring-framework-docs}/web.html#mvc-cors-controller[controller method CORS configuration] with {spring-framework-api}/web/bind/annotation/CrossOrigin.html[`@CrossOrigin`] annotations in your Spring Boot application does not require any specific configuration. {spring-framework-docs}/web.html#mvc-cors-global[Global CORS configuration] can be defined by registering a `WebMvcConfigurer` bean with a customized `addCorsMappings(CorsRegistry)` method, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/developingwebapplications/springmvc/cors/MyCorsConfiguration.java[] ---- @@ -482,19 +482,19 @@ Unlike Spring MVC, it does not require the Servlet API, is fully asynchronous an Spring WebFlux comes in two flavors: functional and annotation-based. The annotation-based one is quite close to the Spring MVC model, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/developingwebapplications/springwebflux/MyRestController.java[] ---- "`WebFlux.fn`", the functional variant, separates the routing configuration from the actual handling of the requests, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/developingwebapplications/springwebflux/MyRoutingConfiguration.java[] ---- -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/developingwebapplications/springwebflux/MyUserHandler.java[] ---- @@ -538,7 +538,7 @@ For example, `+spring.jackson.*+` configuration keys are applied to the Jackson If you need to add or customize codecs, you can create a custom `CodecCustomizer` component, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/developingwebapplications/springwebflux/httpcodecs/MyCodecsConfiguration.java[] ---- @@ -555,7 +555,7 @@ It uses the `ResourceWebHandler` from Spring WebFlux so that you can modify that By default, resources are mapped on `+/**+`, but you can tune that by setting the configprop:spring.webflux.static-path-pattern[] property. For instance, relocating all resources to `/resources/**` can be achieved as follows: -[source,yaml,indent=0,subs="verbatim,quotes,attributes",configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: webflux: @@ -612,7 +612,7 @@ For that, you can add a bean of type `ErrorAttributes`. To change the error handling behavior, you can implement `ErrorWebExceptionHandler` and register a bean definition of that type. Because a `ErrorWebExceptionHandler` is quite low-level, Spring Boot also provides a convenient `AbstractErrorWebExceptionHandler` to let you handle errors in a WebFlux functional way, as shown in the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/developingwebapplications/springwebflux/errorhandling/MyErrorWebExceptionHandler.java[] ---- @@ -622,7 +622,7 @@ For a more complete picture, you can also subclass `DefaultErrorWebExceptionHand In some cases, errors handled at the controller or handler function level are not recorded by the <>. Applications can ensure that such exceptions are recorded with the request metrics by setting the handled exception as a request attribute: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/developingwebapplications/springwebflux/errorhandling/MyExceptionHandlingController.java[] ---- @@ -637,7 +637,7 @@ The name of the file should be the exact status code or a series mask. For example, to map `404` to a static HTML file, your directory structure would be as follows: -[source,indent=0,subs="verbatim,quotes,attributes"] +[source,indent=0,subs="verbatim"] ---- src/ +- main/ @@ -652,7 +652,7 @@ For example, to map `404` to a static HTML file, your directory structure would To map all `5xx` errors by using a Mustache template, your directory structure would be as follows: -[source,indent=0,subs="verbatim,quotes,attributes"] +[source,indent=0,subs="verbatim"] ---- src/ +- main/ @@ -700,7 +700,7 @@ Jersey has some native Spring support, so we also provide auto-configuration sup To get started with Jersey, include the `spring-boot-starter-jersey` as a dependency and then you need one `@Bean` of type `ResourceConfig` in which you register all the endpoints, as shown in the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/developingwebapplications/jersey/MyJerseyConfig.java[] ---- @@ -713,7 +713,7 @@ For more advanced customizations, you can also register an arbitrary number of b All the registered endpoints should be `@Components` with HTTP resource annotations (`@GET` and others), as shown in the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/developingwebapplications/jersey/MyEndpoint.java[] ---- @@ -827,7 +827,7 @@ If you need to programmatically configure your embedded servlet container, you c `WebServerFactoryCustomizer` provides access to the `ConfigurableServletWebServerFactory`, which includes numerous customization setter methods. The following example shows programmatically setting the port: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/developingwebapplications/embeddedcontainer/customizing/programmatic/MyWebServerFactoryCustomizer.java[] ---- @@ -835,7 +835,7 @@ include::{docs-java}/features/developingwebapplications/embeddedcontainer/custom `TomcatServletWebServerFactory`, `JettyServletWebServerFactory` and `UndertowServletWebServerFactory` are dedicated variants of `ConfigurableServletWebServerFactory` that have additional customization setter methods for Tomcat, Jetty and Undertow respectively. The following example shows how to customize `TomcatServletWebServerFactory` that provides access to Tomcat-specific configuration options: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/developingwebapplications/embeddedcontainer/customizing/programmatic/MyTomcatWebServerFactoryCustomizer.java[] ---- diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/email.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/email.adoc index b4fbe84ae2..6409ecb718 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/email.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/email.adoc @@ -10,7 +10,7 @@ See {spring-boot-autoconfigure-module-code}/mail/MailProperties.java[`MailProper In particular, certain default timeout values are infinite, and you may want to change that to avoid having a thread blocked by an unresponsive mail server, as shown in the following example: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: mail: @@ -22,7 +22,7 @@ In particular, certain default timeout values are infinite, and you may want to It is also possible to configure a `JavaMailSender` with an existing `Session` from JNDI: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: mail: diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/external-config.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/external-config.adoc index 021d4051ac..ffa029db31 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/external-config.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/external-config.adoc @@ -38,7 +38,7 @@ If you have configuration files with both `.properties` and `.yml` format in the To provide a concrete example, suppose you develop a `@Component` that uses a `name` property, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/externalconfig/MyBean.java[] ---- @@ -232,7 +232,7 @@ Imports are processed as they are discovered, and are treated as additional docu For example, you might have the following in your classpath `application.properties` file: -[source,yaml,indent=0,configblocks] +[source,yaml,indent=0,subs="verbatim",configblocks] ---- spring: application: @@ -248,7 +248,7 @@ An import will only be imported once no matter how many times it is declared. The order an import is defined inside a single document within the properties/yaml file doesn't matter. For instance, the two examples below produce the same result: -[source,yaml,indent=0,configblocks] +[source,yaml,indent=0,subs="verbatim",configblocks] ---- spring: config: @@ -257,7 +257,7 @@ For instance, the two examples below produce the same result: property: value ---- -[source,yaml,indent=0,configblocks] +[source,yaml,indent=0,subs="verbatim",configblocks] ---- my: property: value @@ -293,7 +293,7 @@ You can do this by putting an extension hint in square brackets. For example, suppose you have a `/etc/config/myconfig` file that you wish to import as yaml. You can import it from your `application.properties` using the following: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: config: @@ -333,7 +333,7 @@ The contents of the `username` file would be a config value, and the contents of To import these properties, you can add the following to your `application.properties` or `application.yaml` file: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: config: @@ -365,7 +365,7 @@ For example, given the following volume: You can use `configtree:/etc/config/*/` as the import location: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: config: @@ -382,7 +382,7 @@ Configuration trees can also be used for Docker secrets. When a Docker swarm service is granted access to a secret, the secret gets mounted into the container. For example, if a secret named `db.password` is mounted at location `/run/secrets/`, you can make `db.password` available to the Spring environment using the following: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: config: @@ -398,7 +398,7 @@ The standard `$\{name}` property-placeholder syntax can be used anywhere within For example, the following file will set `app.description` to "`MyApp is a Spring Boot application`": -[source,yaml,indent=0,configblocks] +[source,yaml,indent=0,subs="verbatim",configblocks] ---- app: name: "MyApp" @@ -421,7 +421,7 @@ Three consecutive hyphens represent the end of one document, and the start of th For example, the following file has two logical documents: -[source,yaml,indent=0] +[source,yaml,indent=0,subs="verbatim"] ---- spring.application.name: MyApp --- @@ -431,7 +431,7 @@ For example, the following file has two logical documents: For `application.properties` files a special `#---` comment is used to mark the document splits: -[source,properties,indent=0] +[source,properties,indent=0,subs="verbatim"] ---- spring.application.name=MyApp #--- @@ -472,7 +472,7 @@ The following activation properties are available: For example, the following specifies that the second document is only active when running on Kubernetes, and only when either the "`prod`" or "`staging`" profiles are active: -[source,yaml,indent=0,configblocks] +[source,yaml,indent=0,subs="verbatim",configblocks] ---- myprop: always-set @@ -511,7 +511,7 @@ NOTE: If you use "`Starters`", SnakeYAML is automatically provided by `spring-bo YAML documents need to be converted from their hierarchical format to a flat structure that can be used with the Spring `Environment`. For example, consider the following YAML document: -[source,yaml,indent=0] +[source,yaml,indent=0,subs="verbatim"] ---- environments: dev: @@ -524,7 +524,7 @@ For example, consider the following YAML document: In order to access these properties from the `Environment`, they would be flattened as follows: -[source,properties,indent=0] +[source,properties,indent=0,subs="verbatim"] ---- environments.dev.url=https://dev.example.com environments.dev.name=Developer Setup @@ -536,7 +536,7 @@ Likewise, YAML lists also need to be flattened. They are represented as property keys with `[index]` dereferencers. For example, consider the following YAML: -[source,yaml,indent=0] +[source,yaml,indent=0,subs="verbatim"] ---- my: servers: @@ -546,7 +546,7 @@ For example, consider the following YAML: The preceding example would be transformed into these properties: -[source,properties,indent=0] +[source,properties,indent=0,subs="verbatim"] ---- my.servers[0]=dev.example.com my.servers[1]=another.example.com @@ -575,7 +575,7 @@ You can also use the `YamlPropertySourceLoader` class if you want to load YAML a The `RandomValuePropertySource` is useful for injecting random values (for example, into secrets or test cases). It can produce integers, longs, uuids, or strings, as shown in the following example: -[source,yaml,indent=0,configblocks] +[source,yaml,indent=0,subs="verbatim",configblocks] ---- my: secret: "${random.value}" @@ -614,7 +614,7 @@ TIP: See also the <`: -[source,properties,indent=0,role="primary"] +[source,properties,indent=0,subs="verbatim",role="primary"] .Properties ---- my.map.[/key1]=value1 @@ -844,7 +844,7 @@ For example, consider binding the following properties to a `Map` my.map./key3=value3 ---- -[source,yaml,indent=0,role="secondary"] +[source,yaml,indent=0,subs="verbatim",role="secondary"] .Yaml ---- my: @@ -894,14 +894,14 @@ When lists are configured in more than one place, overriding works by replacing For example, assume a `MyPojo` object with `name` and `description` attributes that are `null` by default. The following example exposes a list of `MyPojo` objects from `MyProperties`: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/externalconfig/typesafeconfigurationproperties/mergingcomplextypes/list/MyProperties.java[] ---- Consider the following configuration: -[source,yaml,indent=0,configblocks] +[source,yaml,indent=0,subs="verbatim",configblocks] ---- my: list: @@ -924,7 +924,7 @@ This configuration _does not_ add a second `MyPojo` instance to the list, and it When a `List` is specified in multiple profiles, the one with the highest priority (and only that one) is used. Consider the following example: -[source,yaml,indent=0,configblocks] +[source,yaml,indent=0,subs="verbatim",configblocks] ---- my: list: @@ -949,14 +949,14 @@ For `Map` properties, you can bind with property values drawn from multiple sour However, for the same property in multiple sources, the one with the highest priority is used. The following example exposes a `Map` from `MyProperties`: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/externalconfig/typesafeconfigurationproperties/mergingcomplextypes/map/MyProperties.java[] ---- Consider the following configuration: -[source,yaml,indent=0,configblocks] +[source,yaml,indent=0,subs="verbatim",configblocks] ---- my: map: @@ -1006,7 +1006,7 @@ If you expose a `java.time.Duration` property, the following formats in applicat Consider the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/externalconfig/typesafeconfigurationproperties/conversion/durations/javabeanbinding/MyProperties.java[] ---- @@ -1029,7 +1029,7 @@ The default unit is milliseconds and can be overridden using `@DurationUnit` as If you prefer to use constructor binding, the same properties can be exposed, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/externalconfig/typesafeconfigurationproperties/conversion/durations/constructorbinding/MyProperties.java[] ---- @@ -1070,7 +1070,7 @@ If you expose a `DataSize` property, the following formats in application proper Consider the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/externalconfig/typesafeconfigurationproperties/conversion/datasizes/javabeanbinding/MyProperties.java[] ---- @@ -1091,7 +1091,7 @@ The default unit is bytes and can be overridden using `@DataSizeUnit` as illustr If you prefer to use constructor binding, the same properties can be exposed, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/externalconfig/typesafeconfigurationproperties/conversion/datasizes/constructorbinding/MyProperties.java[] ---- @@ -1107,7 +1107,7 @@ Spring Boot attempts to validate `@ConfigurationProperties` classes whenever the You can use JSR-303 `javax.validation` constraint annotations directly on your configuration class. To do so, ensure that a compliant JSR-303 implementation is on your classpath and then add constraint annotations to your fields, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/externalconfig/typesafeconfigurationproperties/validate/MyProperties.java[] ---- @@ -1117,7 +1117,7 @@ TIP: You can also trigger validation by annotating the `@Bean` method that creat To ensure that validation is always triggered for nested properties, even when no properties are found, the associated field must be annotated with `@Valid`. The following example builds on the preceding `MyProperties` example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/externalconfig/typesafeconfigurationproperties/validate/nested/MyProperties.java[] ---- diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/graceful-shutdown.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/graceful-shutdown.adoc index fe14287883..823005a0a3 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/graceful-shutdown.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/graceful-shutdown.adoc @@ -11,7 +11,7 @@ NOTE: Graceful shutdown with Tomcat requires Tomcat 9.0.33 or later. To enable graceful shutdown, configure the configprop:server.shutdown[] property, as shown in the following example: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- server: shutdown: "graceful" @@ -19,7 +19,7 @@ server: To configure the timeout period, configure the configprop:spring.lifecycle.timeout-per-shutdown-phase[] property, as shown in the following example: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: lifecycle: diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/hazelcast.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/hazelcast.adoc index f63b4db165..4e8d8e5466 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/hazelcast.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/hazelcast.adoc @@ -19,7 +19,7 @@ If your configuration defines an instance name, Spring Boot tries to locate an e You could also specify the Hazelcast configuration file to use through configuration, as shown in the following example: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: hazelcast: diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/internationalization.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/internationalization.adoc index 5c46af625b..11a9ca9c96 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/internationalization.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/internationalization.adoc @@ -9,7 +9,7 @@ If no properties file is found that matches any of the configured base names, th The basename of the resource bundle as well as several other attributes can be configured using the `spring.messages` namespace, as shown in the following example: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: messages: diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/jta.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/jta.adoc index ba96642937..611516b9b2 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/jta.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/jta.adoc @@ -41,7 +41,7 @@ Spring Boot tries to auto-configure JMS by looking for a `ConnectionFactory` at When using JTA, the primary JMS `ConnectionFactory` bean is XA-aware and participates in distributed transactions. You can inject into your bean without needing to use any `@Qualifier`: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/jta/mixingxaandnonxaconnections/primary/MyBean.java[tag=*] ---- @@ -51,14 +51,14 @@ For example, your JMS processing logic might take longer than the XA timeout. If you want to use a non-XA `ConnectionFactory`, you can the `nonXaJmsConnectionFactory` bean: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/jta/mixingxaandnonxaconnections/nonxa/MyBean.java[tag=*] ---- For consistency, the `jmsConnectionFactory` bean is also provided by using the bean alias `xaJmsConnectionFactory`: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/jta/mixingxaandnonxaconnections/xa/MyBean.java[tag=*] ---- diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/kotlin.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/kotlin.adoc index fc50b47c1e..58d56db18f 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/kotlin.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/kotlin.adoc @@ -57,7 +57,7 @@ Also be aware that Spring Boot's own API is {github-issues}10712[not yet annotat ==== runApplication Spring Boot provides an idiomatic way to run an application with `runApplication(*args)` as shown in the following example: -[source,kotlin,indent=0] +[source,kotlin,indent=0,subs="verbatim"] ---- import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @@ -73,7 +73,7 @@ Spring Boot provides an idiomatic way to run an application with `runApplication This is a drop-in replacement for `SpringApplication.run(MyApplication::class.java, *args)`. It also allows customization of the application as shown in the following example: -[source,kotlin,indent=0] +[source,kotlin,indent=0,subs="verbatim"] ---- runApplication(*args) { setBannerMode(OFF) @@ -110,7 +110,7 @@ TIP: `org.jetbrains.kotlinx:kotlinx-coroutines-reactor` dependency is provided b === @ConfigurationProperties `@ConfigurationProperties` when used in combination with <> supports classes with immutable `val` properties as shown in the following example: -[source,kotlin,indent=0] +[source,kotlin,indent=0,subs="verbatim"] ---- @ConstructorBinding @ConfigurationProperties("example.kotlin") diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/logging.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/logging.adoc index c6faa538bc..1ad1335a8c 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/logging.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/logging.adoc @@ -73,7 +73,7 @@ You can set `spring.output.ansi.enabled` to a {spring-boot-module-api}/ansi/Ansi Color coding is configured by using the `%clr` conversion word. In its simplest form, the converter colors the output according to the log level, as shown in the following example: -[source,indent=0] +[source,indent=0,subs="verbatim"] ---- %clr(%5p) ---- @@ -105,7 +105,7 @@ The following table describes the mapping of log levels to colors: Alternatively, you can specify the color or style that should be used by providing it as an option to the conversion. For example, to make the text yellow, use the following setting: -[source,indent=0] +[source,indent=0,subs="verbatim"] ---- %clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){yellow} ---- @@ -194,7 +194,7 @@ The `root` logger can be configured by using `logging.level.root`. The following example shows potential logging settings in `application.properties`: -[source,properties,indent=0,subs="verbatim,quotes,attributes",configprops,role="primary"] +[source,properties,indent=0,subs="verbatim",configprops,role="primary"] .Properties ---- logging.level.root=warn @@ -202,7 +202,7 @@ The following example shows potential logging settings in `application.propertie logging.level.org.hibernate=error ---- -[source,properties,indent=0,subs="verbatim,quotes,attributes",role="secondary"] +[source,properties,indent=0,subs="verbatim",role="secondary"] .Yaml ---- logging: @@ -229,7 +229,7 @@ For example, you might commonly change the logging levels for _all_ Tomcat relat To help with this, Spring Boot allows you to define logging groups in your Spring `Environment`. For example, here's how you could define a "`tomcat`" group by adding it to your `application.properties`: -[source,yaml,indent=0,subs="verbatim,quotes,attributes",configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- logging: group: @@ -238,7 +238,7 @@ For example, here's how you could define a "`tomcat`" group by adding it to your Once defined, you can change the level for all the loggers in the group with a single line: -[source,yaml,indent=0,subs="verbatim,quotes,attributes",configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- logging: level: @@ -271,7 +271,7 @@ You can use the configprop:logging.register-shutdown-hook[] property to disable Setting it to `false` will disable the registration. You can set the property in your `application.properties` or `application.yaml` file: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- logging: register-shutdown-hook: false @@ -440,7 +440,7 @@ A profile expression allows for more complicated profile logic to be expressed, Check the {spring-framework-docs}/core.html#beans-definition-profiles-java[reference guide] for more details. The following listing shows three sample profiles: -[source,xml,indent=0] +[source,xml,subs="verbatim",indent=0] ---- @@ -467,7 +467,7 @@ If you need to store the property somewhere other than in `local` scope, you can If you need a fallback value (in case the property is not set in the `Environment`), you can use the `defaultValue` attribute. The following example shows how to expose properties for use within Logback: -[source,xml,indent=0] +[source,xml,subs="verbatim",indent=0] ---- diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/messaging.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/messaging.adoc index aa8b2cdb4c..eaeef4872c 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/messaging.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/messaging.adoc @@ -27,7 +27,7 @@ NOTE: If you use `spring-boot-starter-activemq`, the necessary dependencies to c ActiveMQ configuration is controlled by external configuration properties in `+spring.activemq.*+`. For example, you might declare the following section in `application.properties`: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: activemq: @@ -38,7 +38,7 @@ For example, you might declare the following section in `application.properties` By default, a `CachingConnectionFactory` wraps the native `ConnectionFactory` with sensible settings that you can control by external configuration properties in `+spring.jms.*+`: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: jms: @@ -48,7 +48,7 @@ By default, a `CachingConnectionFactory` wraps the native `ConnectionFactory` wi If you'd rather use native pooling, you can do so by adding a dependency to `org.messaginghub:pooled-jms` and configuring the `JmsPoolConnectionFactory` accordingly, as shown in the following example: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: activemq: @@ -77,7 +77,7 @@ Adding `org.apache.activemq:artemis-jms-server` to your application lets you use ActiveMQ Artemis configuration is controlled by external configuration properties in `+spring.artemis.*+`. For example, you might declare the following section in `application.properties`: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: artemis: @@ -92,7 +92,7 @@ These can be specified as a comma-separated list to create them with the default By default, a `CachingConnectionFactory` wraps the native `ConnectionFactory` with sensible settings that you can control by external configuration properties in `+spring.jms.*+`: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: jms: @@ -102,7 +102,7 @@ By default, a `CachingConnectionFactory` wraps the native `ConnectionFactory` wi If you'd rather use native pooling, you can do so by adding a dependency to `org.messaginghub:pooled-jms` and configuring the `JmsPoolConnectionFactory` accordingly, as shown in the following example: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: artemis: @@ -123,7 +123,7 @@ If you are running your application in an application server, Spring Boot tries By default, the `java:/JmsXA` and `java:/XAConnectionFactory` location are checked. You can use the configprop:spring.jms.jndi-name[] property if you need to specify an alternative location, as shown in the following example: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: jms: @@ -136,7 +136,7 @@ You can use the configprop:spring.jms.jndi-name[] property if you need to specif ==== Sending a Message Spring's `JmsTemplate` is auto-configured, and you can autowire it directly into your own beans, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/messaging/jms/sending/MyBean.java[] ---- @@ -161,7 +161,7 @@ This also includes sending response messages that have been performed on the sam The following component creates a listener endpoint on the `someQueue` destination: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/messaging/jms/receiving/MyBean.java[] ---- @@ -172,14 +172,14 @@ If you need to create more `JmsListenerContainerFactory` instances or if you wan For instance, the following example exposes another factory that uses a specific `MessageConverter`: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/messaging/jms/receiving/custom/MyJmsConfiguration.java[] ---- Then you can use the factory in any `@JmsListener`-annotated method as follows: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/messaging/jms/receiving/custom/MyBean.java[] ---- @@ -202,7 +202,7 @@ Spring uses `RabbitMQ` to communicate through the AMQP protocol. RabbitMQ configuration is controlled by external configuration properties in `+spring.rabbitmq.*+`. For example, you might declare the following section in `application.properties`: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: rabbitmq: @@ -214,7 +214,7 @@ For example, you might declare the following section in `application.properties` Alternatively, you could configure the same connection using the `addresses` attribute: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: rabbitmq: @@ -237,7 +237,7 @@ TIP: See https://spring.io/blog/2010/06/14/understanding-amqp-the-protocol-used- ==== Sending a Message Spring's `AmqpTemplate` and `AmqpAdmin` are auto-configured, and you can autowire them directly into your own beans, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/messaging/amqp/sending/MyBean.java[] ---- @@ -249,7 +249,7 @@ If necessary, any `org.springframework.amqp.core.Queue` that is defined as a bea To retry operations, you can enable retries on the `AmqpTemplate` (for example, in the event that the broker connection is lost): -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: rabbitmq: @@ -274,7 +274,7 @@ If a `MessageConverter` or a `MessageRecoverer` bean is defined, it is automatic The following sample component creates a listener endpoint on the `someQueue` queue: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/messaging/amqp/receiving/MyBean.java[] ---- @@ -288,14 +288,14 @@ Those two beans are exposed by the auto-configuration. For instance, the following configuration class exposes another factory that uses a specific `MessageConverter`: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/messaging/amqp/receiving/custom/MyRabbitConfiguration.java[] ---- Then you can use the factory in any `@RabbitListener`-annotated method, as follows: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/messaging/amqp/receiving/custom/MyBean.java[] ---- @@ -319,7 +319,7 @@ https://kafka.apache.org/[Apache Kafka] is supported by providing auto-configura Kafka configuration is controlled by external configuration properties in `spring.kafka.*`. For example, you might declare the following section in `application.properties`: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: kafka: @@ -339,7 +339,7 @@ See {spring-boot-autoconfigure-module-code}/kafka/KafkaProperties.java[`KafkaPro ==== Sending a Message Spring's `KafkaTemplate` is auto-configured, and you can autowire it directly in your own beans, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/messaging/kafka/sending/MyBean.java[] ---- @@ -356,7 +356,7 @@ If no `KafkaListenerContainerFactory` has been defined, a default one is automat The following component creates a listener endpoint on the `someTopic` topic: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/messaging/kafka/receiving/MyBean.java[] ---- @@ -385,7 +385,7 @@ See also <> for more in To use the factory bean, wire `StreamsBuilder` into your `@Bean` as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/messaging/kafka/streams/MyKafkaStreamsConfiguration.java[] ---- @@ -408,7 +408,7 @@ Spring Boot auto-configuration supports all HIGH importance properties, some sel Only a subset of the properties supported by Kafka are available directly through the `KafkaProperties` class. If you wish to configure the producer or consumer with additional properties that are not directly supported, use the following properties: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: kafka: @@ -432,7 +432,7 @@ This sets the common `prop.one` Kafka property to `first` (applies to producers, You can also configure the Spring Kafka `JsonDeserializer` as follows: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: kafka: @@ -445,7 +445,7 @@ You can also configure the Spring Kafka `JsonDeserializer` as follows: Similarly, you can disable the `JsonSerializer` default behavior of sending type information in headers: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: kafka: @@ -470,21 +470,21 @@ There are several ways to do that: * Provide a system property to map embedded broker addresses into configprop:spring.kafka.bootstrap-servers[] in the test class: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/messaging/kafka/embedded/property/MyTest.java[tag=*] ---- * Configure a property name on the `@EmbeddedKafka` annotation: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/messaging/kafka/embedded/annotation/MyTest.java[] ---- * Use a placeholder in configuration properties: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: kafka: diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/nosql.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/nosql.adoc index e4a37b3a56..9ea66fafe1 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/nosql.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/nosql.adoc @@ -36,7 +36,7 @@ You can inject an auto-configured `RedisConnectionFactory`, `StringRedisTemplate By default, the instance tries to connect to a Redis server at `localhost:6379`. The following listing shows an example of such a bean: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/nosql/redis/connecting/MyBean.java[] ---- @@ -62,7 +62,7 @@ To access MongoDB databases, you can inject an auto-configured `org.springframew By default, the instance tries to connect to a MongoDB server at `mongodb://localhost/test`. The following example shows how to connect to a MongoDB database: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/nosql/mongodb/connecting/MyBean.java[] ---- @@ -77,7 +77,7 @@ Each will be called in order with the `MongoClientSettings.Builder` that is used You can set the configprop:spring.data.mongodb.uri[] property to change the URL and configure additional settings such as the _replica set_, as shown in the following example: -[source,properties,indent=0,configprops] +[source,properties,indent=0,subs="verbatim",configprops] ---- spring.data.mongodb.uri=mongodb://user:secret@mongo1.example.com:12345,mongo2.example.com:23456/test ---- @@ -85,7 +85,7 @@ You can set the configprop:spring.data.mongodb.uri[] property to change the URL Alternatively, you can specify connection details using discrete properties. For example, you might declare the following settings in your `application.properties`: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: data: @@ -113,7 +113,7 @@ The auto-configuration configures this factory automatically if Netty is availab {spring-data-mongodb}[Spring Data MongoDB] provides a {spring-data-mongodb-api}/core/MongoTemplate.html[`MongoTemplate`] class that is very similar in its design to Spring's `JdbcTemplate`. As with `JdbcTemplate`, Spring Boot auto-configures a bean for you to inject the template, as follows: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/nosql/mongodb/template/MyBean.java[] ---- @@ -130,7 +130,7 @@ As with the JPA repositories discussed earlier, the basic principle is that quer In fact, both Spring Data JPA and Spring Data MongoDB share the same common infrastructure. You could take the JPA example from earlier and, assuming that `City` is now a MongoDB data class rather than a JPA `@Entity`, it works in the same way, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/nosql/mongodb/repositories/CityRepository.java[] ---- @@ -172,7 +172,7 @@ To access a Neo4j server, you can inject an auto-configured `org.neo4j.driver.Dr By default, the instance tries to connect to a Neo4j server at `localhost:7687` using the Bolt protocol. The following example shows how to inject a Neo4j `Driver` that gives you access, amongst other things, to a `Session`: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/nosql/neo4j/connecting/MyBean.java[] ---- @@ -180,7 +180,7 @@ include::{docs-java}/features/nosql/neo4j/connecting/MyBean.java[] You can configure various aspects of the driver using `spring.neo4j.*` properties. The following example shows how to configure the uri and credentials to use: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: neo4j: @@ -204,7 +204,7 @@ For complete details of Spring Data Neo4j, refer to the {spring-data-neo4j-docs} Spring Data Neo4j shares the common infrastructure with Spring Data JPA as many other Spring Data modules do. You could take the JPA example from earlier and define `City` as Spring Data Neo4j `@Node` rather than JPA `@Entity` and the repository abstraction works in the same way, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/nosql/neo4j/repositories/CityRepository.java[] ---- @@ -220,7 +220,7 @@ You can customize the locations to look for repositories and entities by using ` In an application using the reactive style, a `ReactiveTransactionManager` is not auto-configured. To enable transaction management, the following bean must be defined in your configuration: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/nosql/neo4j/repositories/MyNeo4jConfiguration.java[] ---- @@ -241,7 +241,7 @@ You can inject an auto-configured `SolrClient` instance as you would any other S By default, the instance tries to connect to a server at `http://localhost:8983/solr`. The following example shows how to inject a Solr bean: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/nosql/solr/connecting/MyBean.java[] ---- @@ -272,7 +272,7 @@ Spring Boot provides support for the "High Level" client, which ships with `org. If you have this dependency on the classpath, Spring Boot will auto-configure and register a `RestHighLevelClient` bean that by default targets `http://localhost:9200`. You can further tune how `RestHighLevelClient` is configured, as shown in the following example: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: elasticsearch: @@ -291,7 +291,7 @@ TIP: If your application needs access to a "Low Level" `RestClient`, you can get Additionally, if `elasticsearch-rest-client-sniffer` is on the classpath, a `Sniffer` is auto-configured to automatically discover nodes from a running Elasticsearch cluster and set them to the `RestHighLevelClient` bean. You can further tune how `Sniffer` is configured, as shown in the following example: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: elasticsearch: @@ -312,7 +312,7 @@ By default, Spring Boot will auto-configure and register a `ReactiveElasticsearc bean that targets `http://localhost:9200`. You can further tune how it is configured, as shown in the following example: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: data: @@ -339,7 +339,7 @@ With this configuration in place, an `ElasticsearchRestTemplate` can be injected like any other Spring bean, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/nosql/elasticsearch/connectingusingspringdata/MyBean.java[] ---- @@ -367,7 +367,7 @@ Same applies to `ReactiveElasticsearchTemplate` and `ReactiveElasticsearchOperat You can choose to disable the repositories support with the following property: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: data: @@ -392,7 +392,7 @@ You can inject an auto-configured `CassandraTemplate` or a Cassandra `CqlSession The `spring.data.cassandra.*` properties can be used to customize the connection. Generally, you provide `keyspace-name` and `contact-points` as well the local datacenter name, as shown in the following example: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: data: @@ -404,7 +404,7 @@ Generally, you provide `keyspace-name` and `contact-points` as well the local da If the port is the same for all your contact points you can use a shortcut and only specify the host names, as shown in the following example: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: data: @@ -432,7 +432,7 @@ NOTE: If you're using `CqlSessionBuilder` to create multiple `CqlSession` beans, The following code listing shows how to inject a Cassandra bean: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/nosql/cassandra/connecting/MyBean.java[] ---- @@ -464,7 +464,7 @@ You can get a `Cluster` by adding the Couchbase SDK and some configuration. The `spring.couchbase.*` properties can be used to customize the connection. Generally, you provide the https://github.com/couchbaselabs/sdk-rfcs/blob/master/rfc/0011-connection-string.md[connection string], username, and password, as shown in the following example: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: couchbase: @@ -476,7 +476,7 @@ Generally, you provide the https://github.com/couchbaselabs/sdk-rfcs/blob/master It is also possible to customize some of the `ClusterEnvironment` settings. For instance, the following configuration changes the timeout to use to open a new `Bucket` and enables SSL support: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: couchbase: @@ -501,7 +501,7 @@ For complete details of Spring Data Couchbase, refer to the {spring-data-couchba You can inject an auto-configured `CouchbaseTemplate` instance as you would with any other Spring Bean, provided a `CouchbaseClientFactory` bean is available. This happens when a `Cluster` is available, as described above, and a bucket name has been specified: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: data: @@ -511,7 +511,7 @@ This happens when a `Cluster` is available, as described above, and a bucket nam The following examples shows how to inject a `CouchbaseTemplate` bean: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/nosql/couchbase/repositories/MyBean.java[] ---- @@ -525,7 +525,7 @@ There are a few beans that you can define in your own configuration to override To avoid hard-coding those names in your own config, you can reuse `BeanNames` provided by Spring Data Couchbase. For instance, you can customize the converters to use, as follows: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/nosql/couchbase/repositories/MyCouchbaseConfiguration.java[] ---- @@ -546,7 +546,7 @@ There is a `spring-boot-starter-data-ldap` "`Starter`" for collecting the depend ==== Connecting to an LDAP Server To connect to an LDAP server, make sure you declare a dependency on the `spring-boot-starter-data-ldap` "`Starter`" or `spring-ldap-core` and then declare the URLs of your server in your application.properties, as shown in the following example: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: ldap: @@ -572,7 +572,7 @@ For complete details of Spring Data LDAP, refer to the https://docs.spring.io/sp You can also inject an auto-configured `LdapTemplate` instance as you would with any other Spring Bean, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/nosql/ldap/repositories/MyBean.java[] ---- @@ -584,7 +584,7 @@ include::{docs-java}/features/nosql/ldap/repositories/MyBean.java[] For testing purposes, Spring Boot supports auto-configuration of an in-memory LDAP server from https://ldap.com/unboundid-ldap-sdk-for-java/[UnboundID]. To configure the server, add a dependency to `com.unboundid:unboundid-ldapsdk` and declare a configprop:spring.ldap.embedded.base-dn[] property, as follows: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: ldap: @@ -598,7 +598,7 @@ It is possible to define multiple base-dn values, however, since distinguished n In yaml files, you can use the yaml list notation. In properties files, you must include the index as part of the property name: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring.ldap.embedded.base-dn: - dc=spring,dc=io @@ -628,7 +628,7 @@ https://www.influxdata.com/[InfluxDB] is an open-source time series database opt ==== Connecting to InfluxDB Spring Boot auto-configures an `InfluxDB` instance, provided the `influxdb-java` client is on the classpath and the URL of the database is set, as shown in the following example: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: influx: diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/profiles.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/profiles.adoc index e2b7de5b82..a414c93093 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/profiles.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/profiles.adoc @@ -15,7 +15,7 @@ You can use a configprop:spring.profiles.active[] `Environment` property to spec You can specify the property in any of the ways described earlier in this chapter. For example, you could include it in your `application.properties`, as shown in the following example: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: profiles: @@ -48,7 +48,7 @@ A profile group allows you to define a logical name for a related group of profi For example, we can create a `production` group that consists of our `proddb` and `prodmq` profiles. -[source,yaml,indent=0,configblocks] +[source,yaml,indent=0,subs="verbatim",configblocks] ---- spring: profiles: diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/quartz.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/quartz.adoc index dab4aba336..1bf925d7eb 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/quartz.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/quartz.adoc @@ -13,7 +13,7 @@ Beans of the following types are automatically picked up and associated with the By default, an in-memory `JobStore` is used. However, it is possible to configure a JDBC-based store if a `DataSource` bean is available in your application and if the configprop:spring.quartz.job-store-type[] property is configured accordingly, as shown in the following example: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: quartz: @@ -22,7 +22,7 @@ However, it is possible to configure a JDBC-based store if a `DataSource` bean i When the JDBC store is used, the schema can be initialized on startup, as shown in the following example: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: quartz: @@ -50,7 +50,7 @@ If you need to customize the task executor, consider implementing `SchedulerFact Jobs can define setters to inject data map properties. Regular beans can also be injected in a similar manner, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/quartz/MySampleJob.java[] ---- diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/resttemplate.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/resttemplate.adoc index b25cae16c6..84e8378b0b 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/resttemplate.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/resttemplate.adoc @@ -7,7 +7,7 @@ The auto-configured `RestTemplateBuilder` ensures that sensible `HttpMessageConv The following code shows a typical example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/resttemplate/MyService.java[] ---- @@ -29,7 +29,7 @@ All such beans are automatically registered with the auto-configured `RestTempla The following example shows a customizer that configures the use of a proxy for all hosts except `192.168.0.5`: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/resttemplate/customization/MyRestTemplateCustomizer.java[] ---- @@ -38,7 +38,7 @@ Finally, you can also create your own `RestTemplateBuilder` bean. To prevent switching off the auto-configuration of a `RestTemplateBuilder` and prevent any `RestTemplateCustomizer` beans from being used, make sure to configure your custom instance with a `RestTemplateBuilderConfigurer`. The following example exposes a `RestTemplateBuilder` with what Spring Boot would auto-configure, except that custom connect and read timeouts are also specified: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/resttemplate/customization/MyRestTemplateBuilderConfiguration.java[] ---- diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/rsocket.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/rsocket.adoc index 3689b037b4..8318b8faf1 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/rsocket.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/rsocket.adoc @@ -35,7 +35,7 @@ This depends on the type of application and its configuration. For WebFlux application (i.e. of type `WebApplicationType.REACTIVE`), the RSocket server will be plugged into the Web Server only if the following properties match: -[source,yaml,indent=0,subs="verbatim,quotes,attributes",configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: rsocket: @@ -49,7 +49,7 @@ WARNING: Plugging RSocket into a web server is only supported with Reactor Netty Alternatively, an RSocket TCP or websocket server is started as an independent, embedded server. Besides the dependency requirements, the only required configuration is to define a port for that server: -[source,yaml,indent=0,subs="verbatim,quotes,attributes",configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: rsocket: @@ -80,7 +80,7 @@ This is done on purpose since this builder is stateful and you shouldn't create The following code shows a typical example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/rsocket//requester/MyService.java[] ---- diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/security.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/security.adoc index 45b278fb41..8875379aee 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/security.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/security.adoc @@ -60,7 +60,7 @@ Spring Boot provides convenience methods that can be used to override access rul For example, you can customize your security configuration by adding something like: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/security/springwebflux/MyWebFluxSecurityConfiguration.java[] ---- @@ -81,7 +81,7 @@ The same properties are applicable to both servlet and reactive applications. You can register multiple OAuth2 clients and providers under the `spring.security.oauth2.client` prefix, as shown in the following example: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: security: @@ -124,7 +124,7 @@ For example, if the `issuer-uri` provided is "https://example.com", then an `Ope The result is expected to be an `OpenID Provider Configuration Response`. The following example shows how an OpenID Connect Provider can be configured with the `issuer-uri`: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: security: @@ -139,7 +139,7 @@ By default, Spring Security's `OAuth2LoginAuthenticationFilter` only processes U If you want to customize the `redirect-uri` to use a different pattern, you need to provide configuration to process that custom pattern. For example, for servlet applications, you can add your own `SecurityFilterChain` that resembles the following: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/security/oauth2/client/MyOAuthClientConfiguration.java[] ---- @@ -159,7 +159,7 @@ Also, if the key for the client registration matches a default supported provide In other words, the two configurations in the following example use the Google provider: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: security: @@ -182,7 +182,7 @@ In other words, the two configurations in the following example use the Google p If you have `spring-security-oauth2-resource-server` on your classpath, Spring Boot can set up an OAuth2 Resource Server. For JWT configuration, a JWK Set URI or OIDC Issuer URI needs to be specified, as shown in the following examples: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: security: @@ -192,7 +192,7 @@ For JWT configuration, a JWK Set URI or OIDC Issuer URI needs to be specified, a jwk-set-uri: "https://example.com/oauth2/default/v1/keys" ---- -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: security: @@ -211,7 +211,7 @@ Alternatively, you can define your own `JwtDecoder` bean for servlet application In cases where opaque tokens are used instead of JWTs, you can configure the following properties to validate tokens via introspection: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: security: @@ -250,7 +250,7 @@ This configuration makes use of the properties under `Saml2RelyingPartyPropertie A relying party registration represents a paired configuration between an Identity Provider, IDP, and a Service Provider, SP. You can register multiple relying parties under the `spring.security.saml2.relyingparty` prefix, as shown in the following example: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: security: diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/spring-application.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/spring-application.adoc index 221236f964..7ebbac3d4c 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/spring-application.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/spring-application.adoc @@ -3,14 +3,14 @@ The `SpringApplication` class provides a convenient way to bootstrap a Spring application that is started from a `main()` method. In many situations, you can delegate to the static `SpringApplication.run` method, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/springapplication/MyApplication.java[] ---- When your application starts, you should see something similar to the following output: -[indent=0,subs="attributes"] +[indent=0,subs="verbatim,attributes"] ---- . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ @@ -71,7 +71,7 @@ To do so, you need to < org.springframework.boot @@ -70,7 +70,7 @@ Production database connections can also be auto-configured by using a pooling ` DataSource configuration is controlled by external configuration properties in `+spring.datasource.*+`. For example, you might declare the following section in `application.properties`: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: datasource: @@ -95,7 +95,7 @@ Refer to the documentation of the connection pool implementation you are using f For instance, if you use the {tomcat-docs}/jdbc-pool.html#Common_Attributes[Tomcat connection pool], you could customize many additional settings, as shown in the following example: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: datasource: @@ -145,7 +145,7 @@ If you deploy your Spring Boot application to an Application Server, you might w The configprop:spring.datasource.jndi-name[] property can be used as an alternative to the configprop:spring.datasource.url[], configprop:spring.datasource.username[], and configprop:spring.datasource.password[] properties to access the `DataSource` from a specific JNDI location. For example, the following section in `application.properties` shows how you can access a JBoss AS defined `DataSource`: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: datasource: @@ -158,14 +158,14 @@ For example, the following section in `application.properties` shows how you can === Using JdbcTemplate Spring's `JdbcTemplate` and `NamedParameterJdbcTemplate` classes are auto-configured, and you can `@Autowire` them directly into your own beans, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/sql/jdbctemplate/MyBean.java[] ---- You can customize some properties of the template by using the `spring.jdbc.template.*` properties, as shown in the following example: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: jdbc: @@ -202,7 +202,7 @@ By default, all packages below your main configuration class (the one annotated Any classes annotated with `@Entity`, `@Embeddable`, or `@MappedSuperclass` are considered. A typical entity class resembles the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/sql/jpaandspringdata/entityclasses/City.java[] ---- @@ -225,7 +225,7 @@ If you use auto-configuration, repositories are searched from the package contai The following example shows a typical Spring Data repository interface definition: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/sql/jpaandspringdata/repositories/CityRepository.java[] ---- @@ -331,7 +331,7 @@ If you use the `jooq-codegen-maven` plugin and you also use the `spring-boot-sta You can also use Spring Boot-defined version variables (such as `h2.version`) to declare the plugin's database dependency. The following listing shows an example: -[source,xml,indent=0] +[source,xml,indent=0,subs="verbatim"] ---- org.jooq @@ -366,7 +366,7 @@ The fluent API offered by jOOQ is initiated through the `org.jooq.DSLContext` in Spring Boot auto-configures a `DSLContext` as a Spring Bean and connects it to your application `DataSource`. To use the `DSLContext`, you can inject it, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/sql/jooq/dslcontext/MyBean.java[tag=!method] ---- @@ -375,7 +375,7 @@ TIP: The jOOQ manual tends to use a variable named `create` to hold the `DSLCont You can then use the `DSLContext` to construct your queries, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/sql/jooq/dslcontext/MyBean.java[tag=method] ---- @@ -409,7 +409,7 @@ Connections are provided via a `ConnectionFactory`, similar to a `DataSource` wi `ConnectionFactory` configuration is controlled by external configuration properties in `+spring.r2dbc.*+`. For example, you might declare the following section in `application.properties`: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: r2dbc: @@ -428,14 +428,14 @@ TIP: The "`How-to`" section includes a <>, Spr You need not provide any connection URLs. You need only include a build dependency to the embedded database that you want to use, as shown in the following example: -[source,xml,indent=0] +[source,xml,indent=0,subs="verbatim"] ---- io.r2dbc @@ -472,7 +472,7 @@ If you want to make sure that each context has a separate embedded database, you ==== Using DatabaseClient A `DatabaseClient` bean is auto-configured, and you can `@Autowire` it directly into your own beans, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/sql/r2dbc/usingdatabaseclient/MyBean.java[] ---- @@ -492,7 +492,7 @@ If you use auto-configuration, repositories are searched from the package contai The following example shows a typical Spring Data repository interface definition: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/sql/r2dbc/repositories/CityRepository.java[] ---- diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/task-execution-and-scheduling.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/task-execution-and-scheduling.adoc index 307c491260..a43c6fc5c1 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/task-execution-and-scheduling.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/task-execution-and-scheduling.adoc @@ -13,7 +13,7 @@ The auto-configured `TaskExecutorBuilder` allows you to easily create instances The thread pool uses 8 core threads that can grow and shrink according to the load. Those default settings can be fine-tuned using the `spring.task.execution` namespace, as shown in the following example: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: task: @@ -30,7 +30,7 @@ Shrinking of the pool is more aggressive as threads are reclaimed when they are A `ThreadPoolTaskScheduler` can also be auto-configured if need to be associated to scheduled task execution (e.g. `@EnableScheduling`). The thread pool uses one thread by default and its settings can be fine-tuned using the `spring.task.scheduling` namespace, as shown in the following example: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: task: diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/testing.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/testing.adoc index ad768efead..f803e14113 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/testing.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/testing.adoc @@ -10,7 +10,7 @@ Most developers use the `spring-boot-starter-test` "`Starter`", which imports bo If you have tests that use JUnit 4, JUnit 5's vintage engine can be used to run them. To use the vintage engine, add a dependency on `junit-vintage-engine`, as shown in the following example: -[source,xml,indent=0,subs="verbatim,quotes,attributes"] +[source,xml,indent=0,subs="verbatim"] ---- org.junit.vintage @@ -105,7 +105,7 @@ If you have only Spring WebFlux, we'll detect that and configure a WebFlux-based If both are present, Spring MVC takes precedence. If you want to test a reactive web application in this scenario, you must set the configprop:spring.main.web-application-type[] property: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/detectingwebapptype/MyWebFluxTests.java[] ---- @@ -148,7 +148,7 @@ As we <>, you can have `@SpringBootTest` inject them using the `args` attribute. -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/usingapplicationarguments/MyApplicationArgumentTests.java[] ---- @@ -175,7 +175,7 @@ include::{docs-java}/features/testing/springbootapplications/usingapplicationarg By default, `@SpringBootTest` does not start the server. If you have web endpoints that you want to test against this mock environment, you can additionally configure {spring-framework-docs}/testing.html#spring-mvc-test-framework[`MockMvc`] as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/withmockenvironment/MyMockMvcTests.java[] ---- @@ -184,7 +184,7 @@ TIP: If you want to focus only on the web layer and not start a complete `Applic Alternatively, you can configure a {spring-framework-docs}/testing.html#webtestclient-tests[`WebTestClient`] as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/withmockenvironment/MyMockWebTestClientTests.java[] ---- @@ -209,7 +209,7 @@ If you use `@SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT)`, an avai The `@LocalServerPort` annotation can be used to <> into your test. For convenience, tests that need to make REST calls to the started server can additionally `@Autowire` a {spring-framework-docs}/testing.html#webtestclient-tests[`WebTestClient`], which resolves relative links to the running server and comes with a dedicated API for verifying responses, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/withrunningserver/MyRandomPortWebTestClientTests.java[] ---- @@ -217,7 +217,7 @@ include::{docs-java}/features/testing/springbootapplications/withrunningserver/M This setup requires `spring-webflux` on the classpath. If you can't or won't add webflux, Spring Boot also provides a `TestRestTemplate` facility: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/withrunningserver/MyRandomPortTestRestTemplateTests.java[] ---- @@ -236,7 +236,7 @@ Any such beans are called with the `WebTestClient.Builder` that is used to creat As the test context framework caches context, JMX is disabled by default to prevent identical components to register on the same domain. If such test needs access to an `MBeanServer`, consider marking it dirty as well: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/jmx/MyJmxTests.java[] ---- @@ -268,7 +268,7 @@ Mock beans are automatically reset after each test method. If your test uses one of Spring Boot's test annotations (such as `@SpringBootTest`), this feature is automatically enabled. To use this feature with a different arrangement, listeners must be explicitly added, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/mockingbeans/listener/MyTests.java[] ---- @@ -277,7 +277,7 @@ include::{docs-java}/features/testing/springbootapplications/mockingbeans/listen The following example replaces an existing `RemoteService` bean with a mock implementation: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/mockingbeans/bean/MyTests.java[] ---- @@ -343,7 +343,7 @@ The `JacksonTester`, `GsonTester`, `JsonbTester`, and `BasicJsonTester` classes Any helper fields on the test class can be `@Autowired` when using `@JsonTest`. The following example shows a test class for Jackson: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/jsontests/MyJsonTests.java[] ---- @@ -355,7 +355,7 @@ If you're using Spring Boot's AssertJ-based helpers to assert on a number value Instead, you can use AssertJ's `satisfies` to assert that the value matches the given condition. For instance, the following example asserts that the actual number is a float value close to `0.15` within an offset of `0.01`. -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/jsontests/MyJsonAssertJTests.java[tag=*] ---- @@ -381,7 +381,7 @@ Mock MVC offers a powerful way to quickly test MVC controllers without needing t TIP: You can also auto-configure `MockMvc` in a non-`@WebMvcTest` (such as `@SpringBootTest`) by annotating it with `@AutoConfigureMockMvc`. The following example uses `MockMvc`: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/springmvctests/MyControllerTests.java[] ---- @@ -391,7 +391,7 @@ TIP: If you need to configure elements of the auto-configuration (for example, w If you use HtmlUnit or Selenium, auto-configuration also provides an HtmlUnit `WebClient` bean and/or a Selenium `WebDriver` bean. The following example uses HtmlUnit: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/springmvctests/MyHtmlUnitTests.java[] ---- @@ -428,7 +428,7 @@ Often, `@WebFluxTest` is limited to a single controller and used in combination TIP: You can also auto-configure `WebTestClient` in a non-`@WebFluxTest` (such as `@SpringBootTest`) by annotating it with `@AutoConfigureWebTestClient`. The following example shows a class that uses both `@WebFluxTest` and a `WebTestClient`: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/springwebfluxtests/MyControllerTests.java[] ---- @@ -457,7 +457,7 @@ TIP: A list of the auto-configuration settings that are enabled by `@DataCassand The following example shows a typical setup for using Cassandra tests in Spring Boot: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/autoconfiguredspringdatacassandra/MyDataCassandraTests.java[] ---- @@ -481,7 +481,7 @@ By default, data JPA tests are transactional and roll back at the end of each te See the {spring-framework-docs}/testing.html#testcontext-tx-enabling-transactions[relevant section] in the Spring Framework Reference Documentation for more details. If that is not what you want, you can disable transaction management for a test or for the whole class as follows: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/autoconfiguredspringdatajpa/MyNonTransactionalTests.java[] ---- @@ -491,7 +491,7 @@ If you want to use `TestEntityManager` outside of `@DataJpaTest` instances, you A `JdbcTemplate` is also available if you need that. The following example shows the `@DataJpaTest` annotation in use: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/autoconfiguredspringdatajpa/withoutdb/MyRepositoryTests.java[] ---- @@ -499,7 +499,7 @@ include::{docs-java}/features/testing/springbootapplications/autoconfiguredsprin In-memory embedded databases generally work well for tests, since they are fast and do not require any installation. If, however, you prefer to run tests against a real database you can use the `@AutoConfigureTestDatabase` annotation, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/autoconfiguredspringdatajpa/withdb/MyRepositoryTests.java[] ---- @@ -519,7 +519,7 @@ By default, JDBC tests are transactional and roll back at the end of each test. See the {spring-framework-docs}/testing.html#testcontext-tx-enabling-transactions[relevant section] in the Spring Framework Reference Documentation for more details. If that is not what you want, you can disable transaction management for a test or for the whole class, as follows: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/autoconfiguredjdbc/MyTransactionalTests.java[] ---- @@ -561,7 +561,7 @@ TIP: A list of the auto-configurations that are enabled by `@JooqTest` can be << `@JooqTest` configures a `DSLContext`. The following example shows the `@JooqTest` annotation in use: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/autoconfiguredjooq/MyJooqTests.java[] ---- @@ -583,7 +583,7 @@ TIP: A list of the auto-configuration settings that are enabled by `@DataMongoTe The following class shows the `@DataMongoTest` annotation in use: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/autoconfiguredspringdatamongodb/withoutdb/MyDataMongoDbTests.java[] ---- @@ -591,7 +591,7 @@ include::{docs-java}/features/testing/springbootapplications/autoconfiguredsprin In-memory embedded MongoDB generally works well for tests, since it is fast and does not require any developer installation. If, however, you prefer to run tests against a real MongoDB server, you should exclude the embedded MongoDB auto-configuration, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/autoconfiguredspringdatamongodb/withdb/MyDataMongoDbTests.java[] ---- @@ -610,7 +610,7 @@ TIP: A list of the auto-configuration settings that are enabled by `@DataNeo4jTe The following example shows a typical setup for using Neo4J tests in Spring Boot: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/autoconfiguredspringdataneo4j/propagation/MyDataNeo4jTests.java[] ---- @@ -619,7 +619,7 @@ By default, Data Neo4j tests are transactional and roll back at the end of each See the {spring-framework-docs}/testing.html#testcontext-tx-enabling-transactions[relevant section] in the Spring Framework Reference Documentation for more details. If that is not what you want, you can disable transaction management for a test or for the whole class, as follows: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/autoconfiguredspringdataneo4j/nopropagation/MyDataNeo4jTests.java[] ---- @@ -641,7 +641,7 @@ TIP: A list of the auto-configuration settings that are enabled by `@DataRedisTe The following example shows the `@DataRedisTest` annotation in use: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/autoconfiguredspringdataredis/MyDataRedisTests.java[] ---- @@ -660,7 +660,7 @@ TIP: A list of the auto-configuration settings that are enabled by `@DataLdapTes The following example shows the `@DataLdapTest` annotation in use: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/autoconfiguredspringdataldap/inmemory/MyDataLdapTests.java[] ---- @@ -668,7 +668,7 @@ include::{docs-java}/features/testing/springbootapplications/autoconfiguredsprin In-memory embedded LDAP generally works well for tests, since it is fast and does not require any developer installation. If, however, you prefer to run tests against a real LDAP server, you should exclude the embedded LDAP auto-configuration, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/autoconfiguredspringdataldap/server/MyDataLdapTests.java[] ---- @@ -686,7 +686,7 @@ TIP: A list of the auto-configuration settings that are enabled by `@RestClientT The specific beans that you want to test should be specified by using the `value` or `components` attribute of `@RestClientTest`, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/autoconfiguredrestclient/MyRestClientTests.java[] ---- @@ -708,14 +708,14 @@ It can also be used to configure the host, scheme, and port that appears in any `@AutoConfigureRestDocs` customizes the `MockMvc` bean to use Spring REST Docs when testing Servlet-based web applications. You can inject it by using `@Autowired` and use it in your tests as you normally would when using Mock MVC and Spring REST Docs, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/MyUserDocumentationTests.java[] ---- If you require more control over Spring REST Docs configuration than offered by the attributes of `@AutoConfigureRestDocs`, you can use a `RestDocsMockMvcConfigurationCustomizer` bean, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/MyRestDocsConfiguration.java[] ---- @@ -724,7 +724,7 @@ If you want to make use of Spring REST Docs support for a parameterized output d The auto-configuration calls `alwaysDo` with this result handler, thereby causing each `MockMvc` call to automatically generate the default snippets. The following example shows a `RestDocumentationResultHandler` being defined: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/MyResultHandlerConfiguration.java[] ---- @@ -736,14 +736,14 @@ include::{docs-java}/features/testing/springbootapplications/autoconfiguredsprin `@AutoConfigureRestDocs` can also be used with `WebTestClient` when testing reactive web applications. You can inject it by using `@Autowired` and use it in your tests as you normally would when using `@WebFluxTest` and Spring REST Docs, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyUsersDocumentationTests.java[] ---- If you require more control over Spring REST Docs configuration than offered by the attributes of `@AutoConfigureRestDocs`, you can use a `RestDocsWebTestClientConfigurationCustomizer` bean, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyRestDocsConfiguration.java[] ---- @@ -755,14 +755,14 @@ include::{docs-java}/features/testing/springbootapplications/autoconfiguredsprin `@AutoConfigureRestDocs` makes a `RequestSpecification` bean, preconfigured to use Spring REST Docs, available to your tests. You can inject it by using `@Autowired` and use it in your tests as you normally would when using REST Assured and Spring REST Docs, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/autoconfiguredspringrestdocs/withrestassured/MyUserDocumentationTests.java[] ---- If you require more control over Spring REST Docs configuration than offered by the attributes of `@AutoConfigureRestDocs`, a `RestDocsRestAssuredConfigurationCustomizer` bean can be used, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/autoconfiguredspringrestdocs/withrestassured/MyRestDocsConfiguration.java[] ---- @@ -780,7 +780,7 @@ TIP: A list of the auto-configuration settings that are enabled by `@WebServiceC The following example shows the `@WebServiceClientTest` annotation in use: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/autoconfiguredwebservices/MyWebServiceClientTests.java[] ---- @@ -792,7 +792,7 @@ include::{docs-java}/features/testing/springbootapplications/autoconfiguredwebse Each slice provides one or more `@AutoConfigure...` annotations that namely defines the auto-configurations that should be included as part of a slice. Additional auto-configurations can be added on a test-by-test basis by creating a custom `@AutoConfigure...` annotation or by adding `@ImportAutoConfiguration` to the test as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/additionalautoconfigurationandslicing/MyJdbcTests.java[] ---- @@ -819,7 +819,7 @@ It then becomes important not to litter the application's main class with config Assume that you are using Spring Batch and you rely on the auto-configuration for it. You could define your `@SpringBootApplication` as follows: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/userconfigurationandslicing/MyApplication.java[] ---- @@ -827,7 +827,7 @@ include::{docs-java}/features/testing/springbootapplications/userconfigurationan Because this class is the source configuration for the test, any slice test actually tries to start Spring Batch, which is definitely not what you want to do. A recommended approach is to move that area-specific configuration to a separate `@Configuration` class at the same level as your application, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/userconfigurationandslicing/MyBatchConfiguration.java[] ---- @@ -838,14 +838,14 @@ The latter approach lets you enable it in one of your tests, if necessary, with Test slices exclude `@Configuration` classes from scanning. For example, for a `@WebMvcTest`, the following configuration will not include the given `WebMvcConfigurer` bean in the application context loaded by the test slice: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/userconfigurationandslicing/MyWebConfiguration.java[] ---- The configuration below will, however, cause the custom `WebMvcConfigurer` to be loaded by the test slice. -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/userconfigurationandslicing/MyWebMvcConfigurer.java[] ---- @@ -854,7 +854,7 @@ Another source of confusion is classpath scanning. Assume that, while you structured your code in a sensible way, you need to scan an additional package. Your application may resemble the following code: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/springbootapplications/userconfigurationandslicing/scan/MyApplication.java[] ---- @@ -890,7 +890,7 @@ A few test utility classes that are generally useful when testing your applicati `ConfigDataApplicationContextInitializer` is an `ApplicationContextInitializer` that you can apply to your tests to load Spring Boot `application.properties` files. You can use it when you do not need the full set of features provided by `@SpringBootTest`, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/utilities/configdataapplicationcontextinitializer/MyConfigFileTests.java[] ---- @@ -906,7 +906,7 @@ For `@Value` support, you need to either additionally configure a `PropertySourc `TestPropertyValues` lets you quickly add properties to a `ConfigurableEnvironment` or `ConfigurableApplicationContext`. You can call it with `key=value` strings, as follows: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/utilities/testpropertyvalues/MyEnvironmentTests.java[] ---- @@ -918,7 +918,7 @@ include::{docs-java}/features/testing/utilities/testpropertyvalues/MyEnvironment `OutputCapture` is a JUnit `Extension` that you can use to capture `System.out` and `System.err` output. To use add `@ExtendWith(OutputCaptureExtension.class)` and inject `CapturedOutput` as an argument to your test class constructor or test method as follows: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/utilities/outputcapture/MyOutputCaptureTests.java[] ---- @@ -943,7 +943,7 @@ If you do use Apache's HTTP client, some additional test-friendly features are e `TestRestTemplate` can be instantiated directly in your integration tests, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/utilities/testresttemplate/MyTests.java[] ---- @@ -952,7 +952,7 @@ Alternatively, if you use the `@SpringBootTest` annotation with `WebEnvironment. If necessary, additional customizations can be applied through the `RestTemplateBuilder` bean. Any URLs that do not specify a host and port automatically connect to the embedded server, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/testing/utilities/testresttemplate/MySpringBootTests.java[] ---- diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/validation.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/validation.adoc index 74684fe488..009b5dd324 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/validation.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/validation.adoc @@ -6,7 +6,7 @@ Target classes with such annotated methods need to be annotated with the `@Valid For instance, the following service triggers the validation of the first argument, making sure its size is between 8 and 10: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/validation/MyBean.java[] ---- diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/webclient.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/webclient.adoc index b25a880f8e..5a6abc1e04 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/webclient.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/webclient.adoc @@ -9,7 +9,7 @@ Spring Boot is configuring that builder to share HTTP resources, reflect codecs The following code shows a typical example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/webclient/MyService.java[] ---- diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/webservices.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/webservices.adoc index 8c470f4707..f345260b99 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/webservices.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/webservices.adoc @@ -8,7 +8,7 @@ The {spring-webservices-docs}[Spring Web Services features] can be easily access To do so, configure their location, as shown in the following example: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: webservices: @@ -25,7 +25,7 @@ It does, however, auto-configure a `WebServiceTemplateBuilder`, which can be use The following code shows a typical example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/webservices/template/MyService.java[] ---- @@ -33,7 +33,7 @@ include::{docs-java}/features/webservices/template/MyService.java[] By default, `WebServiceTemplateBuilder` detects a suitable HTTP-based `WebServiceMessageSender` using the available HTTP client libraries on the classpath. You can also customize read and connection timeouts as follows: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/features/webservices/template/MyWebServiceTemplateConfiguration.java[] ---- diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/websockets.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/websockets.adoc index 28952f2894..479ee79850 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/websockets.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/websockets.adoc @@ -7,7 +7,7 @@ Spring Framework provides {spring-framework-docs}/web.html#websocket[rich WebSoc WebSocket support is also available for {spring-framework-docs}/web-reactive.html#webflux-websocket[reactive web applications] and requires to include the WebSocket API alongside `spring-boot-starter-webflux`: -[source,xml,indent=0,subs="verbatim,quotes,attributes"] +[source,xml,indent=0,subs="verbatim"] ---- javax.websocket diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/getting-started/first-application.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/getting-started/first-application.adoc index f0758be629..f5e1cfab7c 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/getting-started/first-application.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/getting-started/first-application.adoc @@ -42,7 +42,7 @@ We need to start by creating a Maven `pom.xml` file. The `pom.xml` is the recipe that is used to build your project. Open your favorite text editor and add the following: -[source,xml,indent=0,subs="verbatim,quotes,attributes"] +[source,xml,indent=0,subs="verbatim,attributes"] ---- @@ -149,7 +149,7 @@ If you run `mvn dependency:tree` again, you see that there are now a number of a To finish our application, we need to create a single Java file. By default, Maven compiles sources from `src/main/java`, so you need to create that directory structure and then add a file named `src/main/java/MyApplication.java` to contain the following code: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/gettingstarted/firstapplication/code/MyApplication.java[] ---- @@ -208,7 +208,7 @@ Since you used the `spring-boot-starter-parent` POM, you have a useful `run` goa Type `mvn spring-boot:run` from the root project directory to start the application. You should see output similar to the following: -[indent=0,subs="attributes"] +[indent=0,subs="verbatim,attributes"] ---- $ mvn spring-boot:run @@ -257,7 +257,7 @@ Spring Boot takes a <> and le To create an executable jar, we need to add the `spring-boot-maven-plugin` to our `pom.xml`. To do so, insert the following lines just below the `dependencies` section: -[source,xml,indent=0,subs="verbatim,quotes,attributes"] +[source,xml,indent=0,subs="verbatim"] ---- @@ -275,7 +275,7 @@ See the {spring-boot-maven-plugin-docs}#getting-started[plugin documentation] fo Save your `pom.xml` and run `mvn package` from the command line, as follows: -[indent=0,subs="attributes"] +[indent=0,subs="verbatim,attributes"] ---- $ mvn package @@ -308,7 +308,7 @@ This is the original jar file that Maven created before it was repackaged by Spr To run that application, use the `java -jar` command, as follows: -[indent=0,subs="attributes"] +[indent=0,subs="verbatim,attributes"] ---- $ java -jar target/myproject-0.0.1-SNAPSHOT.jar diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/getting-started/installing.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/getting-started/installing.adoc index 5a6752e06a..50c995c8ca 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/getting-started/installing.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/getting-started/installing.adoc @@ -93,7 +93,7 @@ Alternatively, you can use `java -jar` with the `.jar` file (the script helps yo SDKMAN! (The Software Development Kit Manager) can be used for managing multiple versions of various binary SDKs, including Groovy and the Spring Boot CLI. Get SDKMAN! from https://sdkman.io and install Spring Boot by using the following commands: -[indent=0,subs="verbatim,quotes,attributes"] +[indent=0,subs="verbatim,attributes"] ---- $ sdk install springboot $ spring --version @@ -102,7 +102,7 @@ Get SDKMAN! from https://sdkman.io and install Spring Boot by using the followin If you develop features for the CLI and want access to the version you built, use the following commands: -[indent=0,subs="verbatim,quotes,attributes"] +[indent=0,subs="verbatim,attributes"] ---- $ sdk install springboot dev /path/to/spring-boot/spring-boot-cli/target/spring-boot-cli-{spring-boot-version}-bin/spring-{spring-boot-version}/ $ sdk default springboot dev @@ -115,7 +115,7 @@ It points at your target build location, so every time you rebuild Spring Boot, You can see it by running the following command: -[indent=0,subs="verbatim,quotes,attributes"] +[indent=0,subs="verbatim,attributes"] ---- $ sdk ls springboot @@ -202,7 +202,7 @@ In that case, run `scoop update` and try again. You can use the following web application to test your installation. To start, create a file called `app.groovy`, as follows: -[source,groovy,indent=0,subs="verbatim,quotes,attributes"] +[source,groovy,indent=0,pending-extract=true,subs="verbatim"] ---- @RestController class ThisWillActuallyRun { @@ -244,7 +244,7 @@ When upgrading to a new feature release, some properties may have been renamed o Spring Boot provides a way to analyze your application's environment and print diagnostics at startup, but also temporarily migrate properties at runtime for you. To enable that feature, add the following dependency to your project: -[source,xml,indent=0] +[source,xml,indent=0,subs="verbatim"] ---- org.springframework.boot diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/actuator.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/actuator.adoc index 1604013993..1474d98067 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/actuator.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/actuator.adoc @@ -66,7 +66,7 @@ To export these, you'll need to convert these states to some set of numbers so t The following example shows one way to write such an exporter: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/howto/actuator/maphealthindicatorstometrics/MyHealthMetricsExportConfiguration.java[] ---- diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/application.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/application.adoc index 202fba8820..9f1be91f32 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/application.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/application.adoc @@ -17,7 +17,7 @@ If, for whatever reason, you cannot handle the exception, return `null` to give `FailureAnalyzer` implementations must be registered in `META-INF/spring.factories`. The following example registers `ProjectConstraintViolationFailureAnalyzer`: -[source,properties,indent=0] +[source,properties,indent=0,subs="verbatim"] ---- org.springframework.boot.diagnostics.FailureAnalyzer=\ com.example.ProjectConstraintViolationFailureAnalyzer @@ -78,7 +78,7 @@ Each implementation should be registered in `META-INF/spring.factories`, as show The implementation can load arbitrary files and add them to the `Environment`. For instance, the following example loads a YAML configuration file from the classpath: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/howto/application/customizetheenvironmentorapplicationcontext/MyEnvironmentPostProcessor.java[] ---- diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/batch.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/batch.adoc index 508990bfd6..7ab5d5ce25 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/batch.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/batch.adoc @@ -35,7 +35,7 @@ Spring Boot converts any command line argument starting with `--` to a property This should not be used to pass arguments to batch jobs. To specify batch arguments on the command line, use the regular format (i.e. without `--`), as shown in the following example: -[indent=0,subs="attributes"] +[indent=0,subs="verbatim"] ---- $ java -jar myapp.jar someParameter=someValue anotherParameter=anotherValue ---- @@ -43,7 +43,7 @@ To specify batch arguments on the command line, use the regular format (i.e. wit If you specify a property of the `Environment` on the command line, it is ignored by the job. Consider the following command: -[indent=0,subs="attributes"] +[indent=0,subs="verbatim"] ---- $ java -jar myapp.jar --server.port=7070 someParameter=someValue ---- diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/build.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/build.adoc index be19adab48..d964b6d26b 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/build.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/build.adoc @@ -13,7 +13,7 @@ When such a file is present, Spring Boot auto-configures a `BuildProperties` bea To generate build information with Maven, add an execution for the `build-info` goal, as shown in the following example: -[source,xml,indent=0,subs="verbatim,quotes,attributes"] +[source,xml,indent=0,subs="verbatim,attributes"] ---- @@ -37,7 +37,7 @@ TIP: See the {spring-boot-maven-plugin-docs}#goals-build-info[Spring Boot Maven The following example does the same with Gradle: -[source,gradle,indent=0,subs="verbatim,attributes"] +[source,gradle,indent=0,subs="verbatim"] ---- springBoot { buildInfo() @@ -55,7 +55,7 @@ Both Maven and Gradle allow generating a `git.properties` file containing inform For Maven users, the `spring-boot-starter-parent` POM includes a pre-configured plugin to generate a `git.properties` file. To use it, add the following declaration to your POM: -[source,xml,indent=0] +[source,xml,indent=0,subs="verbatim"] ---- @@ -69,7 +69,7 @@ To use it, add the following declaration to your POM: Gradle users can achieve the same result by using the https://plugins.gradle.org/plugin/com.gorylenko.gradle-git-properties[`gradle-git-properties`] plugin, as shown in the following example: -[source,gradle,indent=0] +[source,gradle,indent=0,subs="verbatim"] ---- plugins { id "com.gorylenko.gradle-git-properties" version "2.2.4" @@ -103,7 +103,7 @@ To override dependency versions in Gradle, see {spring-boot-gradle-plugin-docs}# The `spring-boot-maven-plugin` can be used to create an executable "`fat`" JAR. If you use the `spring-boot-starter-parent` POM, you can declare the plugin and your jars are repackaged as follows: -[source,xml,indent=0,subs="verbatim,quotes,attributes"] +[source,xml,indent=0,subs="verbatim"] ---- @@ -118,7 +118,7 @@ If you use the `spring-boot-starter-parent` POM, you can declare the plugin and If you do not use the parent POM, you can still use the plugin. However, you must additionally add an `` section, as follows: -[source,xml,indent=0,subs="verbatim,quotes,attributes"] +[source,xml,indent=0,subs="verbatim"] ---- @@ -157,7 +157,7 @@ This classifier is applied to the name of the executable archive, leaving the de To configure a classifier of `exec` in Maven, you can use the following configuration: -[source,xml,indent=0,subs="verbatim,quotes,attributes"] +[source,xml,indent=0,subs="verbatim"] ---- @@ -187,7 +187,7 @@ WARNING: Care should be taken to ensure that your operating system is configured For example, to indicate that JRuby should be flagged for unpacking by using the Maven Plugin, you would add the following configuration: -[source,xml,indent=0,subs="verbatim,quotes,attributes"] +[source,xml,indent=0,subs="verbatim"] ---- @@ -216,7 +216,7 @@ For example, the `application.yml` configuration file might be excluded from the In Maven, the executable jar must be the main artifact and you can add a classified jar for the library, as follows: -[source,xml,indent=0,subs="verbatim,quotes,attributes"] +[source,xml,indent=0,subs="verbatim"] ---- @@ -272,7 +272,7 @@ To make it executable, you can either use the `spring-boot-antlib` module or you The following example shows how to build an executable archive with Ant: -[source,xml,indent=0] +[source,xml,indent=0,subs="verbatim"] ---- diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/data-access.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/data-access.adoc index e984bc5ddc..3a5357475a 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/data-access.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/data-access.adoc @@ -13,14 +13,14 @@ If you need to externalize some settings, you can bind your `DataSource` to the The following example shows how to define a data source in a bean: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/howto/dataaccess/configurecustomdatasource/custom/MyDataSourceConfiguration.java[] ---- The following example shows how to define a data source by setting properties: -[source,yaml,indent=0,configblocks] +[source,yaml,indent=0,subs="verbatim",configblocks] ---- app: datasource: @@ -37,7 +37,7 @@ It also auto-detects the driver based on the JDBC URL. The following example shows how to create a data source by using a `DataSourceBuilder`: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/howto/dataaccess/configurecustomdatasource/builder/MyDataSourceConfiguration.java[] ---- @@ -48,7 +48,7 @@ Check the implementation that is going to be used at runtime for more details. The following example shows how to define a JDBC data source by setting properties: -[source,yaml,indent=0,configblocks] +[source,yaml,indent=0,subs="verbatim",configblocks] ---- app: datasource: @@ -63,7 +63,7 @@ Because the actual type of the connection pool is not exposed, no keys are gener Also, if you happen to have Hikari on the classpath, this basic setup does not work, because Hikari has no `url` property (but does have a `jdbcUrl` property). In that case, you must rewrite your configuration as follows: -[source,yaml,indent=0,configblocks] +[source,yaml,indent=0,subs="verbatim",configblocks] ---- app: datasource: @@ -78,7 +78,7 @@ You cannot change the implementation at runtime, but the list of options will be The following example shows how create a `HikariDataSource` with `DataSourceBuilder`: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/howto/dataaccess/configurecustomdatasource/simple/MyDataSourceConfiguration.java[] ---- @@ -88,7 +88,7 @@ You can easily initialize a `DataSourceBuilder` from the state of any `DataSourc However, that would split your configuration into two namespaces: `url`, `username`, `password`, `type`, and `driver` on `spring.datasource` and the rest on your custom namespace (`app.datasource`). To avoid that, you can redefine a custom `DataSourceProperties` on your custom namespace, as shown in the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/howto/dataaccess/configurecustomdatasource/configurable/MyDataSourceConfiguration.java[] ---- @@ -96,7 +96,7 @@ include::{docs-java}/howto/dataaccess/configurecustomdatasource/configurable/MyD This setup puts you _in sync_ with what Spring Boot does for you by default, except that a dedicated connection pool is chosen (in code) and its settings are exposed in the `app.datasource.configuration` sub namespace. Because `DataSourceProperties` is taking care of the `url`/`jdbcUrl` translation for you, you can configure it as follows: -[source,yaml,indent=0,configblocks] +[source,yaml,indent=0,subs="verbatim",configblocks] ---- app: datasource: @@ -125,7 +125,7 @@ You must, however, mark one of the `DataSource` instances as `@Primary`, because If you create your own `DataSource`, the auto-configuration backs off. In the following example, we provide the _exact_ same feature set as the auto-configuration provides on the primary data source: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/howto/dataaccess/configuretwodatasources/MyDataSourcesConfiguration.java[] ---- @@ -135,7 +135,7 @@ TIP: `firstDataSourceProperties` has to be flagged as `@Primary` so that the dat Both data sources are also bound for advanced customizations. For instance, you could configure them as follows: -[source,yaml,indent=0,configblocks] +[source,yaml,indent=0,subs="verbatim",configblocks] ---- app: datasource: @@ -155,7 +155,7 @@ For instance, you could configure them as follows: You can apply the same concept to the secondary `DataSource` as well, as shown in the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/howto/dataaccess/configuretwodatasources/MyCompleteDataSourcesConfiguration.java[] ---- @@ -186,7 +186,7 @@ For more about Spring Data, see the {spring-data}[Spring Data project page]. Spring Boot tries to guess the location of your `@Entity` definitions, based on the `@EnableAutoConfiguration` it finds. To get more control, you can use the `@EntityScan` annotation, as shown in the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/howto/dataaccess/separateentitydefinitionsfromspringconfiguration/MyApplication.java[] ---- @@ -207,7 +207,7 @@ If you prefer to set the dialect yourself, set the configprop:spring.jpa.databas The most common options to set are shown in the following example: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: jpa: @@ -242,21 +242,21 @@ Alternatively, if `ImplicitNamingStrategy` or `PhysicalNamingStrategy` beans are By default, Spring Boot configures the physical naming strategy with `SpringPhysicalNamingStrategy`. This implementation provides the same table structure as Hibernate 4: all dots are replaced by underscores and camel casing is replaced by underscores as well. Additionally, by default, all table names are generated in lower case. For example, a `TelephoneNumber` entity is mapped to the `telephone_number` table. If your schema requires mixed-case identifiers, define a custom `SpringPhysicalNamingStrategy` bean, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/howto/dataaccess/configurehibernatenamingstrategy/spring/MyHibernateConfiguration.java[] ---- If you prefer to use Hibernate 5's default instead, set the following property: -[indent=0,subs="verbatim,quotes,attributes"] +[indent=0,properties,subs="verbatim"] ---- spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl ---- Alternatively, you can configure the following bean: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/howto/dataaccess/configurehibernatenamingstrategy/standard/MyHibernateConfiguration.java[] ---- @@ -273,7 +273,7 @@ Rather than configuring Hibernate to lookup the cache provider again, it is bett To do this with JCache, first make sure that `org.hibernate:hibernate-jcache` is available on the classpath. Then, add a `HibernatePropertiesCustomizer` bean as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/howto/dataaccess/configurehibernatesecondlevelcaching/MyHibernateSecondLevelCacheConfiguration.java[] ---- @@ -306,7 +306,7 @@ If you need to use JPA against multiple data sources, you likely need one `Entit The `LocalContainerEntityManagerFactoryBean` from Spring ORM allows you to configure an `EntityManagerFactory` for your needs. You can also reuse `JpaProperties` to bind settings for each `EntityManagerFactory`, as shown in the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/howto/dataaccess/usemultipleentitymanagers/MyEntityManagerFactoryConfiguration.java[] ---- @@ -325,12 +325,12 @@ Alternatively, you might be able to use a JTA transaction manager that spans bot If you use Spring Data, you need to configure `@EnableJpaRepositories` accordingly, as shown in the following examples: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/howto/dataaccess/usemultipleentitymanagers/OrderConfiguration.java[] ---- -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/howto/dataaccess/usemultipleentitymanagers/CustomerConfiguration.java[] ---- @@ -390,7 +390,7 @@ For example, when Flyway is auto-configured, Hibernate is configured to depend u If you are configuring a component yourself, you can use an `EntityManagerFactoryDependsOnPostProcessor` subclass as a convenient way of setting up the necessary dependencies. For example, if you use Hibernate Search with Elasticsearch as its index manager, any `EntityManagerFactory` beans must be configured to depend on the `elasticsearchClient` bean, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/howto/dataaccess/configureacomponentthatisusedbyjpa/ElasticsearchEntityManagerFactoryDependsOnPostProcessor.java[] ---- diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/data-initialization.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/data-initialization.adoc index c13895492f..9f89371dda 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/data-initialization.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/data-initialization.adoc @@ -66,7 +66,7 @@ Spring Boot can detect your database type and execute those scripts on startup. If you use an embedded database, this happens by default. You can also enable it for any database type, as shown in the following example: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: batch: @@ -93,7 +93,7 @@ By default, they are in a directory called `classpath:db/migration`, but you can This is a comma-separated list of one or more `classpath:` or `filesystem:` locations. For example, the following configuration would search for scripts in both the default classpath location and the `/opt/migration` directory: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: flyway: @@ -103,7 +103,7 @@ For example, the following configuration would search for scripts in both the de You can also add a special `\{vendor}` placeholder to use vendor-specific scripts. Assume the following: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: flyway: @@ -141,7 +141,7 @@ For example, you can place test-specific migrations in `src/test/resources` and Also, you can use profile-specific configuration to customize `spring.flyway.locations` so that certain migrations run only when a particular profile is active. For example, in `application-dev.properties`, you might specify the following setting: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: flyway: diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/http-clients.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/http-clients.adoc index e7a2357e31..540e7a5737 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/http-clients.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/http-clients.adoc @@ -20,7 +20,7 @@ When Reactor Netty is on the classpath a Reactor Netty-based `WebClient` is auto To customize the client's handling of network connections, provide a `ClientHttpConnector` bean. The following example configures a 60 second connect timeout and adds a `ReadTimeoutHandler`: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/howto/httpclients/webclientreactornettycustomization/MyReactorNettyClientConfiguration.java[] ---- diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/jedis-instead-of-lettuce.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/jedis-instead-of-lettuce.adoc index 882b79bee4..7cea12e54e 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/jedis-instead-of-lettuce.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/jedis-instead-of-lettuce.adoc @@ -6,7 +6,7 @@ Spring Boot manages both of these dependencies so you can switch to Jedis withou The following example shows how to do so in Maven: -[source,xml,indent=0,subs="verbatim,quotes,attributes"] +[source,xml,indent=0,subs="verbatim"] ---- org.springframework.boot @@ -26,7 +26,7 @@ The following example shows how to do so in Maven: The following example shows how to do so in Gradle: -[source,gradle,indent=0,subs="verbatim,quotes,attributes"] +[source,gradle,indent=0,subs="verbatim"] ---- dependencies { implementation('org.springframework.boot:spring-boot-starter-data-redis') { diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/jersey.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/jersey.adoc index ff525ede80..d81c2eb326 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/jersey.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/jersey.adoc @@ -11,7 +11,7 @@ This prevents Jersey from committing the response before Spring Security has had The `jersey.config.server.response.setStatusOverSendError` property must be set to `true` on the application's `ResourceConfig` bean, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/howto/jersey/springsecurity/JerseySetStatusOverSendErrorConfig.java[] ---- @@ -24,7 +24,7 @@ To use Jersey alongside another web framework, such as Spring MVC, it should be First, configure Jersey to use a Filter rather than a Servlet by configuring the configprop:spring.jersey.type[] application property with a value of `filter`. Second, configure your `ResourceConfig` to forward requests that would have resulted in a 404, as shown in the following example. -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/howto/jersey/alongsideanotherwebframework/JerseyConfig.java[] ---- diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/logging.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/logging.adoc index 7efd4cb152..90a7552108 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/logging.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/logging.adoc @@ -6,7 +6,7 @@ The recommended way to do that is through the starters, which all depend on `spr For a web application, you need only `spring-boot-starter-web`, since it depends transitively on the logging starter. If you use Maven, the following dependency adds logging for you: -[source,xml,indent=0,subs="verbatim,quotes,attributes"] +[source,xml,indent=0,subs="verbatim"] ---- org.springframework.boot @@ -19,7 +19,7 @@ If Logback is available, it is the first choice. If the only change you need to make to logging is to set the levels of various loggers, you can do so in `application.properties` by using the "logging.level" prefix, as shown in the following example: -[source,yaml,indent=0,subs="verbatim,quotes,attributes",configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- logging: level: @@ -55,7 +55,7 @@ In addition, a legacy `base.xml` file is provided for compatibility with earlier A typical custom `logback.xml` file would look something like this: -[source,xml,indent=0,subs="verbatim,quotes,attributes"] +[source,xml,indent=0,subs="verbatim"] ---- @@ -91,7 +91,7 @@ Any `logback-spring.groovy` files will not be detected. ==== Configure Logback for File-only Output If you want to disable console logging and write output only to a file, you need a custom `logback-spring.xml` that imports `file-appender.xml` but not `console-appender.xml`, as shown in the following example: -[source,xml,indent=0,subs="verbatim,quotes,attributes"] +[source,xml,indent=0,subs="verbatim"] ---- @@ -106,7 +106,7 @@ If you want to disable console logging and write output only to a file, you need You also need to add `logging.file.name` to your `application.properties` or `application.yaml`, as shown in the following example: -[source,yaml,indent=0,subs="verbatim,quotes,attributes",configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- logging: file: @@ -124,7 +124,7 @@ If you do not use the starters, you need to provide (at least) `spring-jcl` in a The recommended path is through the starters, even though it requires some jiggling. The following example shows how to set up the starters in Maven: -[source,xml,indent=0,subs="verbatim,quotes,attributes"] +[source,xml,indent=0,subs="verbatim"] ---- org.springframework.boot @@ -148,7 +148,7 @@ The following example shows how to set up the starters in Maven: And the following example shows one way to set up the starters in Gradle: -[source,gradle,indent=0,subs="verbatim,quotes,attributes"] +[source,gradle,indent=0,subs="verbatim"] ---- dependencies { compile 'org.springframework.boot:spring-boot-starter-web' diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/messaging.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/messaging.adoc index fdb9fdae85..88dc397b53 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/messaging.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/messaging.adoc @@ -11,7 +11,7 @@ If your JMS broker does not support transacted sessions, you have to disable the If you create your own `JmsListenerContainerFactory`, there is nothing to do, since, by default it cannot be transacted. If you want to use the `DefaultJmsListenerContainerFactoryConfigurer` to reuse Spring Boot's default, you can disable transacted sessions, as follows: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/howto/messaging/disabletransactedjmssession/MyJmsConfiguration.java[] ---- diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/properties-and-configuration.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/properties-and-configuration.adoc index 44d344c3a6..f14e43d486 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/properties-and-configuration.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/properties-and-configuration.adoc @@ -16,7 +16,7 @@ This is possible in both Maven and Gradle. You can automatically expand properties from the Maven project by using resource filtering. If you use the `spring-boot-starter-parent`, you can then refer to your Maven '`project properties`' with `@..@` placeholders, as shown in the following example: -[source,yaml,indent=0,configblocks] +[source,yaml,indent=0,subs="verbatim",configblocks] ---- app: encoding: "@project.build.sourceEncoding@" @@ -33,7 +33,7 @@ See the {spring-boot-maven-plugin-docs}#getting-started[plugin usage page] for m If you do not use the starter parent, you need to include the following element inside the `` element of your `pom.xml`: -[source,xml,indent=0] +[source,xml,indent=0,subs="verbatim"] ---- @@ -45,7 +45,7 @@ If you do not use the starter parent, you need to include the following element You also need to include the following element inside ``: -[source,xml,indent=0] +[source,xml,indent=0,subs="verbatim"] ---- org.apache.maven.plugins @@ -69,7 +69,7 @@ If that property is not set to `false`, these may be expanded by the build. ==== Automatic Property Expansion Using Gradle You can automatically expand properties from the Gradle project by configuring the Java plugin's `processResources` task to do so, as shown in the following example: -[source,gradle,indent=0] +[source,gradle,indent=0,subs="verbatim"] ---- processResources { expand(project.properties) @@ -78,7 +78,7 @@ You can automatically expand properties from the Gradle project by configuring t You can then refer to your Gradle project's properties by using placeholders, as shown in the following example: -[source,yaml,indent=0,configblocks] +[source,yaml,indent=0,subs="verbatim",configblocks] ---- app: name: "${name}" @@ -97,7 +97,7 @@ A `SpringApplication` has bean property setters, so you can use its Java API as Alternatively, you can externalize the configuration by setting properties in `+spring.main.*+`. For example, in `application.properties`, you might have the following settings: -[source,yaml,indent=0,subs="verbatim,quotes,attributes",configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: main: @@ -110,21 +110,21 @@ Then the Spring Boot banner is not printed on startup, and the application is no Properties defined in external configuration override and replace the values specified with the Java API, with the notable exception of the primary sources. Primary sources are those provided to the `SpringApplication` constructor: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/howto/propertiesandconfiguration/externalizeconfiguration/application/MyApplication.java[] ---- Or to `sources(...)` method of a `SpringApplicationBuilder`: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/howto/propertiesandconfiguration/externalizeconfiguration/builder/MyApplication.java[] ---- Given the examples above, if we have the following configuration: -[source,yaml,indent=0,subs="verbatim,quotes,attributes",configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: main: @@ -165,7 +165,7 @@ See {spring-boot-module-code}/context/config/ConfigFileApplicationListener.java[ Some people like to use (for example) `--port=9000` instead of `--server.port=9000` to set configuration properties on the command line. You can enable this behavior by using placeholders in `application.properties`, as shown in the following example: -[source,yaml,indent=0,subs="verbatim,quotes,attributes",configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- server: port: "${port:8080}" @@ -183,7 +183,7 @@ In those two platforms, the `PORT` environment variable is set automatically and === Use YAML for External Properties YAML is a superset of JSON and, as such, is a convenient syntax for storing external properties in a hierarchical format, as shown in the following example: -[source,yaml,indent=0,subs="verbatim,quotes,attributes"] +[source,yaml,indent=0,subs="verbatim"] ---- spring: application: @@ -201,7 +201,7 @@ A YAML file is parsed to a Java `Map` (like a JSON object), and S The preceding example YAML corresponds to the following `application.properties` file: -[source,properties,indent=0,subs="verbatim,quotes,attributes",configprops] +[source,properties,indent=0,subs="verbatim",configprops] ---- spring.application.name=cruncher spring.datasource.driver-class-name=com.mysql.jdbc.Driver @@ -218,14 +218,14 @@ See "`<>`" in the '`Spring Boot features The Spring `Environment` has an API for this, but you would normally set a System property (configprop:spring.profiles.active[]) or an OS environment variable (configprop:spring.profiles.active[format=envvar]). Also, you can launch your application with a `-D` argument (remember to put it before the main class or jar archive), as follows: -[indent=0,subs="verbatim,quotes,attributes"] +[indent=0,subs="verbatim"] ---- $ java -jar -Dspring.profiles.active=production demo-0.0.1-SNAPSHOT.jar ---- In Spring Boot, you can also set the active profile in `application.properties`, as shown in the following example: -[source,yaml,indent=0,subs="verbatim,quotes,attributes",configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: profiles: @@ -246,7 +246,7 @@ Spring Boot supports multi-document YAML and Properties files (see < com.fasterxml.jackson.dataformat @@ -36,7 +36,7 @@ To use the Jackson XML renderer, add the following dependency to your project: If Jackson's XML extension is not available and JAXB is available, XML can be rendered with the additional requirement of having `MyThing` annotated as `@XmlRootElement`, as shown in the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/howto/springmvc/writexmlrestservice/MyThing.java[] ---- @@ -44,7 +44,7 @@ include::{docs-java}/howto/springmvc/writexmlrestservice/MyThing.java[] JAXB is only available out of the box with Java 8. If you're using a more recent Java generation, add the following dependency to your project: -[source,xml,indent=0,subs="verbatim,quotes,attributes"] +[source,xml,indent=0,subs="verbatim"] ---- org.glassfish.jaxb diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/testcontainers.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/testcontainers.adoc index acb921aa93..5bc25198e7 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/testcontainers.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/testcontainers.adoc @@ -5,7 +5,7 @@ It integrates with JUnit, allowing you to write a test class that can start up a Testcontainers is especially useful for writing integration tests that talk to a real backend service such as MySQL, MongoDB, Cassandra etc. Testcontainers can be used in a Spring Boot test as follows: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/howto/testcontainers/vanilla/MyIntegrationTests.java ---- @@ -15,7 +15,7 @@ In most cases, you will need to configure the application using details from the This can be done with a static `@DynamicPropertySource` method that allows adding dynamic property values to the Spring Environment. -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/howto/testcontainers/dynamicproperties/MyIntegrationTests.java ---- diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/testing-with-spring-security.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/testing-with-spring-security.adoc index c759d4b263..74687f51b8 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/testing-with-spring-security.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/testing-with-spring-security.adoc @@ -3,7 +3,7 @@ Spring Security provides support for running tests as a specific user. For example, the test in the snippet below will run with an authenticated user that has the `ADMIN` role. -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/howto/testingwithspringsecurity/MySecurityTests.java[] ---- diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/traditional-deployment.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/traditional-deployment.adoc index f4e1ffcb0b..87a454c984 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/traditional-deployment.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/traditional-deployment.adoc @@ -14,7 +14,7 @@ The first step in producing a deployable war file is to provide a `SpringBootSer Doing so makes use of Spring Framework's Servlet 3.0 support and lets you configure your application when it is launched by the servlet container. Typically, you should update your application's main class to extend `SpringBootServletInitializer`, as shown in the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/howto/traditionaldeployment/war/MyApplication.java[] ---- @@ -22,14 +22,14 @@ include::{docs-java}/howto/traditionaldeployment/war/MyApplication.java[] The next step is to update your build configuration such that your project produces a war file rather than a jar file. If you use Maven and `spring-boot-starter-parent` (which configures Maven's war plugin for you), all you need to do is to modify `pom.xml` to change the packaging to war, as follows: -[source,xml,indent=0,subs="verbatim,quotes,attributes"] +[source,xml,indent=0,subs="verbatim"] ---- war ---- If you use Gradle, you need to modify `build.gradle` to apply the war plugin to the project, as follows: -[source,gradle,indent=0,subs="verbatim,quotes,attributes"] +[source,gradle,indent=0,subs="verbatim"] ---- apply plugin: 'war' ---- @@ -39,7 +39,7 @@ To do so, you need to mark the embedded servlet container dependency as being pr If you use Maven, the following example marks the servlet container (Tomcat, in this case) as being provided: -[source,xml,indent=0,subs="verbatim,quotes,attributes"] +[source,xml,indent=0,subs="verbatim"] ---- @@ -54,7 +54,7 @@ If you use Maven, the following example marks the servlet container (Tomcat, in If you use Gradle, the following example marks the servlet container (Tomcat, in this case) as being provided: -[source,gradle,indent=0,subs="verbatim,quotes,attributes"] +[source,gradle,indent=0,subs="verbatim"] ---- dependencies { // … @@ -79,7 +79,7 @@ See the https://spring.io/guides/gs/convert-jar-to-war/[Getting Started Guide on To create a deployable war by extending `SpringBootServletInitializer` (for example, in a class called `Application`) and adding the Spring Boot `@SpringBootApplication` annotation, use code similar to that shown in the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/howto/traditionaldeployment/convertexistingapplication/MyApplication.java[tag=!main] ---- @@ -101,7 +101,7 @@ If you have other features in your application (for instance, using other servle Once the war file is working, you can make it executable by adding a `main` method to your `Application`, as shown in the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/howto/traditionaldeployment/convertexistingapplication/MyApplication.java[tag=main] ---- @@ -110,7 +110,7 @@ include::{docs-java}/howto/traditionaldeployment/convertexistingapplication/MyAp ==== If you intend to start your application as a war or as an executable application, you need to share the customizations of the builder in a method that is both available to the `SpringBootServletInitializer` callback and in the `main` method in a class similar to the following: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/howto/traditionaldeployment/convertexistingapplication/both/MyApplication.java[] ---- @@ -144,7 +144,7 @@ To deploy a Spring Boot application to WebLogic, you must ensure that your servl A typical initializer for WebLogic should resemble the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/howto/traditionaldeployment/weblogic/MyApplication.java[] ---- @@ -152,7 +152,7 @@ include::{docs-java}/howto/traditionaldeployment/weblogic/MyApplication.java[] If you use Logback, you also need to tell WebLogic to prefer the packaged version rather than the version that was pre-installed with the server. You can do so by adding a `WEB-INF/weblogic.xml` file with the following contents: -[source,xml,indent=0] +[source,xml,indent=0,subs="verbatim"] ---- 3.1.0 @@ -46,7 +46,7 @@ If you wish to use Jetty 10, which does support Servlet 4.0, override the `jetty The following Gradle example shows how to use Undertow in place of Reactor Netty for Spring WebFlux: -[source,gradle,indent=0,subs="verbatim,quotes,attributes"] +[source,gradle,indent=0,subs="verbatim"] ---- configurations.all { resolutionStrategy.dependencySubstitution.all { dependency -> @@ -71,7 +71,7 @@ NOTE: `spring-boot-starter-reactor-netty` is required to use the `WebClient` cla If your classpath contains the necessary bits to start a web server, Spring Boot will automatically start it. To disable this behavior configure the `WebApplicationType` in your `application.properties`, as shown in the following example: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: main: @@ -104,7 +104,7 @@ The best way to get that and be sure it has been initialized is to add a `@Bean` Tests that use `@SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT)` can also inject the actual port into a field by using the `@LocalServerPort` annotation, as shown in the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/howto/webserver/discoverport/MyWebIntegrationTests.java[] ---- @@ -124,7 +124,7 @@ Contrary to a test, application code callbacks are processed early (before the v HTTP response compression is supported by Jetty, Tomcat, and Undertow. It can be enabled in `application.properties`, as follows: -[source,yaml,indent=0,subs="verbatim,quotes,attributes",configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- server: compression: @@ -154,7 +154,7 @@ You can configure this behavior by setting the configprop:server.compression.mim SSL can be configured declaratively by setting the various `+server.ssl.*+` properties, typically in `application.properties` or `application.yml`. The following example shows setting SSL properties in `application.properties`: -[source,yaml,indent=0,subs="verbatim,quotes,attributes",configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- server: port: 8443 @@ -194,7 +194,7 @@ More on this in the https://tomcat.apache.org/tomcat-9.0-doc/apr.html[official T Starting Tomcat 9.0.x on JDK 8 with HTTP/2 and SSL enabled but without that native support logs the following error: -[indent=0,subs="attributes"] +[indent=0,subs="verbatim"] ---- ERROR 8787 --- [ main] o.a.coyote.http11.Http11NioProtocol : The upgrade handler [org.apache.coyote.http2.Http2Protocol] for [h2] only supports upgrade via ALPN but has been configured for the ["https-jsse-nio-8443"] connector that does not support ALPN. ---- @@ -246,7 +246,7 @@ You can declare such a component and get access to the server factory relevant t The example below is for Tomcat with the `spring-boot-starter-web` (Servlet stack): -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/howto/webserver/configure/MyTomcatWebServerCustomizer.java[] ---- @@ -319,7 +319,7 @@ Like any other Spring bean, you can define the order of Servlet filter beans; pl As <>, any `Servlet` or `Filter` beans are registered with the servlet container automatically. To disable registration of a particular `Filter` or `Servlet` bean, create a registration bean for it and mark it as disabled, as shown in the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/howto/webserver/addservletfilterlistener/springbean/disable/MyFilterConfiguration.java[] ---- @@ -339,7 +339,7 @@ Access logs can be configured for Tomcat, Undertow, and Jetty through their resp For instance, the following settings log access on Tomcat with a {tomcat-docs}/config/valve.html#Access_Logging[custom pattern]. -[source,yaml,indent=0,subs="verbatim,quotes,attributes",configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- server: tomcat: @@ -355,7 +355,7 @@ In the preceding example, the logs are available in `my-tomcat/logs` relative to Access logging for Undertow can be configured in a similar fashion, as shown in the following example: -[source,yaml,indent=0,subs="verbatim,quotes,attributes",configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- server: undertow: @@ -369,7 +369,7 @@ You can customize this location by setting the configprop:server.undertow.access Finally, access logging for Jetty can also be configured as follows: -[source,yaml,indent=0,subs="verbatim,quotes,attributes",configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- server: jetty: @@ -410,7 +410,7 @@ In all other instances, it defaults to `NONE`. ==== Customize Tomcat's Proxy Configuration If you use Tomcat, you can additionally configure the names of the headers used to carry "`forwarded`" information, as shown in the following example: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- server: tomcat: @@ -423,7 +423,7 @@ Tomcat is also configured with a default regular expression that matches interna By default, IP addresses in `10/8`, `192.168/16`, `169.254/16` and `127/8` are trusted. You can customize the valve's configuration by adding an entry to `application.properties`, as shown in the following example: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- server: tomcat: @@ -441,7 +441,7 @@ You can take complete control of the configuration of Tomcat's `RemoteIpValve` b === Enable Multiple Connectors with Tomcat You can add an `org.apache.catalina.connector.Connector` to the `TomcatServletWebServerFactory`, which can allow multiple connectors, including HTTP and HTTPS connectors, as shown in the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/howto/webserver/enablemultipleconnectorsintomcat/MyTomcatConfiguration.java[] ---- @@ -461,7 +461,7 @@ If at all possible, you should consider updating your code to only store values If, however, you cannot change the way that cookies are written, you can instead configure Tomcat to use a `LegacyCookieProcessor`. To switch to the `LegacyCookieProcessor`, use an `WebServerFactoryCustomizer` bean that adds a `TomcatContextCustomizer`, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/howto/webserver/usetomcatlegacycookieprocessor/MyLegacyCookieProcessorConfiguration.java[] ---- @@ -474,7 +474,7 @@ Embedded Tomcat's MBean registry is disabled by default. This minimizes Tomcat's memory footprint. If you want to use Tomcat's MBeans, for example so that they can be used to expose metrics via Micrometer, you must use the configprop:server.tomcat.mbeanregistry.enabled[] property to do so, as shown in the following example: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- server: tomcat: @@ -488,7 +488,7 @@ server: === Enable Multiple Listeners with Undertow Add an `UndertowBuilderCustomizer` to the `UndertowServletWebServerFactory` and add a listener to the `Builder`, as shown in the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/howto/webserver/enablemultiplelistenersinundertow/MyUndertowConfiguration.java[] ---- @@ -499,7 +499,7 @@ include::{docs-java}/howto/webserver/enablemultiplelistenersinundertow/MyUnderto === Create WebSocket Endpoints Using @ServerEndpoint If you want to use `@ServerEndpoint` in a Spring Boot application that used an embedded container, you must declare a single `ServerEndpointExporter` `@Bean`, as shown in the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/howto/webserver/createwebsocketendpointsusingserverendpoint/MyWebSocketConfiguration.java[] ---- diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/using/auto-configuration.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/using/auto-configuration.adoc index d2fcc2c28a..d96ad65421 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/using/auto-configuration.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/using/auto-configuration.adoc @@ -25,7 +25,7 @@ Doing so enables debug logs for a selection of core loggers and logs a condition === Disabling Specific Auto-configuration Classes If you find that specific auto-configuration classes that you do not want are being applied, you can use the exclude attribute of `@SpringBootApplication` to disable them, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/using/autoconfiguration/disablingspecific/MyApplication.java[] ---- diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/using/build-systems.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/using/build-systems.adoc index 52605a7c75..78b5241225 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/using/build-systems.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/using/build-systems.adoc @@ -47,7 +47,7 @@ The `spring-boot-antlib` "`AntLib`" module is also available to help Ant create To declare dependencies, a typical `ivy.xml` file looks something like the following example: -[source,xml,indent=0] +[source,xml,indent=0,subs="verbatim"] ---- @@ -64,7 +64,7 @@ To declare dependencies, a typical `ivy.xml` file looks something like the follo A typical `build.xml` looks like the following example: -[source,xml,indent=0,subs="verbatim,quotes,attributes"] +[source,xml,indent=0,subs="verbatim,attributes"] ---- @@ -17,7 +17,7 @@ To include devtools support, add the module dependency to your build, as shown i ---- .Gradle -[source,gradle,indent=0,subs="attributes"] +[source,gradle,indent=0,subs="verbatim"] ---- dependencies { developmentOnly("org.springframework.boot:spring-boot-devtools") @@ -117,7 +117,7 @@ The report shows the changes to your application's auto-configuration as you mak To disable the logging of the report, set the following property: -[source,yaml,indent=0,configblocks] +[source,yaml,indent=0,subs="verbatim",configblocks] ---- spring: devtools: @@ -135,7 +135,7 @@ By default, changing resources in `/META-INF/maven`, `/META-INF/resources`, `/re If you want to customize these exclusions, you can use the configprop:spring.devtools.restart.exclude[] property. For example, to exclude only `/static` and `/public` you would set the following property: -[source,yaml,indent=0,configblocks] +[source,yaml,indent=0,subs="verbatim",configblocks] ---- spring: devtools: @@ -162,7 +162,7 @@ In most cases, you can set this property in your `application.properties` (doing If you need to _completely_ disable restart support (for example, because it does not work with a specific library), you need to set the configprop:spring.devtools.restart.enabled[] `System` property to `false` before calling `SpringApplication.run(...)`, as shown in the following example: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/devtools/restart/disable/MyApplication.java[] ---- @@ -191,7 +191,7 @@ For example, if you have a project with the following structure: Then your `trigger-file` property would be: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: devtools: @@ -224,7 +224,7 @@ The `spring-devtools.properties` file can contain properties prefixed with `rest The `include` elements are items that should be pulled up into the "`restart`" classloader, and the `exclude` elements are items that should be pushed down into the "`base`" classloader. The value of the property is a regex pattern that is applied to the classpath, as shown in the following example: -[source,yaml,indent=0,configblocks] +[source,yaml,indent=0,subs="verbatim",configblocks] ---- restart: exclude: @@ -277,7 +277,7 @@ You can configure global devtools settings by adding any of the following files Any properties added to these file apply to _all_ Spring Boot applications on your machine that use devtools. For example, to configure restart to always use a <>, you would add the following property to your `spring-boot-devtools` file: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: devtools: @@ -304,7 +304,7 @@ Profile specific filenames (of the form `spring-boot-devtools-.properti Since Spring Boot relies entirely on the IDE to compile and copy files into the location from where Spring Boot can read them, you might find that there are times when certain changes are not reflected when devtools restarts the application. If you observe such problems constantly, try increasing the `spring.devtools.restart.poll-interval` and `spring.devtools.restart.quiet-period` parameters to the values that fit your development environment: -[source,yaml,indent=0,configprops,configblocks] +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ---- spring: devtools: @@ -328,7 +328,7 @@ You should never enable support on a production deployment. To enable it, you need to make sure that `devtools` is included in the repackaged archive, as shown in the following listing: -[source,xml,indent=0,subs="verbatim,quotes,attributes"] +[source,xml,indent=0,subs="verbatim"] ---- @@ -368,7 +368,7 @@ For example, if you are using Eclipse or STS and you have a project named `my-ap A running remote client might resemble the following listing: -[indent=0,subs="attributes"] +[indent=0,subs="verbatim"] ---- . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ ___ _ \ \ \ \ diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/using/running-your-application.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/using/running-your-application.adoc index 3f80a4b21c..4eea5ac5d4 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/using/running-your-application.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/using/running-your-application.adoc @@ -30,7 +30,7 @@ STS users can use the `Relaunch` button rather than the `Run` button to ensure t === Running as a Packaged Application If you use the Spring Boot Maven or Gradle plugins to create an executable jar, you can run your application using `java -jar`, as shown in the following example: -[indent=0,subs="attributes"] +[indent=0,subs="verbatim"] ---- $ java -jar target/myapplication-0.0.1-SNAPSHOT.jar ---- @@ -38,7 +38,7 @@ If you use the Spring Boot Maven or Gradle plugins to create an executable jar, It is also possible to run a packaged application with remote debugging support enabled. Doing so lets you attach a debugger to your packaged application, as shown in the following example: -[indent=0,subs="attributes"] +[indent=0,subs="verbatim"] ---- $ java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8000,suspend=n \ -jar target/myapplication-0.0.1-SNAPSHOT.jar @@ -52,14 +52,14 @@ The Spring Boot Maven plugin includes a `run` goal that can be used to quickly c Applications run in an exploded form, as they do in your IDE. The following example shows a typical Maven command to run a Spring Boot application: -[indent=0,subs="attributes"] +[indent=0,subs="verbatim"] ---- $ mvn spring-boot:run ---- You might also want to use the `MAVEN_OPTS` operating system environment variable, as shown in the following example: -[indent=0,subs="attributes"] +[indent=0,subs="verbatim"] ---- $ export MAVEN_OPTS=-Xmx1024m ---- @@ -71,14 +71,14 @@ You might also want to use the `MAVEN_OPTS` operating system environment variabl The Spring Boot Gradle plugin also includes a `bootRun` task that can be used to run your application in an exploded form. The `bootRun` task is added whenever you apply the `org.springframework.boot` and `java` plugins and is shown in the following example: -[indent=0,subs="attributes"] +[indent=0,subs="verbatim"] ---- $ gradle bootRun ---- You might also want to use the `JAVA_OPTS` operating system environment variable, as shown in the following example: -[indent=0,subs="attributes"] +[indent=0,subs="verbatim"] ---- $ export JAVA_OPTS=-Xmx1024m ---- diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/using/spring-beans-and-dependency-injection.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/using/spring-beans-and-dependency-injection.adoc index 7dd3f916cb..1c0347bba5 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/using/spring-beans-and-dependency-injection.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/using/spring-beans-and-dependency-injection.adoc @@ -8,14 +8,14 @@ All of your application components (`@Component`, `@Service`, `@Repository`, `@C The following example shows a `@Service` Bean that uses constructor injection to obtain a required `RiskAssessor` bean: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/using/springbeansanddependencyinjection/singleconstructor/MyAccountService.java[] ---- If a bean has more than one constructor, you'll need to mark the one you want Spring to use with `@Autowired`: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/using/springbeansanddependencyinjection/multipleconstructors/MyAccountService.java[] ---- diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/using/structuring-your-code.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/using/structuring-your-code.adoc index 33aa2cd28e..a3b022a007 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/using/structuring-your-code.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/using/structuring-your-code.adoc @@ -48,7 +48,7 @@ The following listing shows a typical layout: The `MyApplication.java` file would declare the `main` method, along with the basic `@SpringBootApplication`, as follows: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/using/structuringyourcode/locatingthemainclass/MyApplication.java[] ---- diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/using/using-the-springbootapplication-annotation.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/using/using-the-springbootapplication-annotation.adoc index b274994a98..598f6178c7 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/using/using-the-springbootapplication-annotation.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/using/using-the-springbootapplication-annotation.adoc @@ -7,7 +7,7 @@ A single `@SpringBootApplication` annotation can be used to enable those three f * `@ComponentScan`: enable `@Component` scan on the package where the application is located (see <>) * `@Configuration`: allow to register extra beans in the context or import additional configuration classes -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/using/usingthespringbootapplicationannotation/springapplication/MyApplication.java[] ---- @@ -19,7 +19,7 @@ NOTE: `@SpringBootApplication` also provides aliases to customize the attributes None of these features are mandatory and you may choose to replace this single annotation by any of the features that it enables. For instance, you may not want to use component scan or configuration properties scan in your application: -[source,java,indent=0] +[source,java,indent=0,subs="verbatim"] ---- include::{docs-java}/using/usingthespringbootapplicationannotation/individualannotations/MyApplication.java[] ----