Avoid trivialising what the reader's learning about

Closes gh-22408
pull/22550/head
Andy Wilkinson 4 years ago
parent 4a0031a21e
commit 179d2c79d6

@ -1,7 +1,7 @@
= Contributing to Spring Boot = Contributing to Spring Boot
Spring Boot is released under the Apache 2.0 license. If you would like to contribute Spring Boot is released under the Apache 2.0 license. If you would like to contribute
something, or simply want to hack on the code this document should help you get started. something, or want to hack on the code this document should help you get started.
@ -55,7 +55,7 @@ added after the original pull request but before a merge.
`./mvnw io.spring.javaformat:spring-javaformat-maven-plugin:apply`. `./mvnw io.spring.javaformat:spring-javaformat-maven-plugin:apply`.
* The build includes checkstyle rules for many of our code conventions. Run * The build includes checkstyle rules for many of our code conventions. Run
`./mvnw validate` if you want to check you changes are compliant. `./mvnw validate` if you want to check you changes are compliant.
* Make sure all new `.java` files to have a simple Javadoc class comment with at least an * Make sure all new `.java` files have a Javadoc class comment with at least an
`@author` tag identifying you, and preferably at least a paragraph on what the class is `@author` tag identifying you, and preferably at least a paragraph on what the class is
for. for.
* Add the ASF license header comment to all new `.java` files (copy from existing files * Add the ASF license header comment to all new `.java` files (copy from existing files

@ -1,7 +1,7 @@
= Spring Boot image:https://ci.spring.io/api/v1/teams/spring-boot/pipelines/spring-boot-2.1.x/jobs/build/badge["Build Status", link="https://ci.spring.io/teams/spring-boot/pipelines/spring-boot-2.1.x?groups=Build"] image:https://badges.gitter.im/Join Chat.svg["Chat",link="https://gitter.im/spring-projects/spring-boot?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge"] = Spring Boot image:https://ci.spring.io/api/v1/teams/spring-boot/pipelines/spring-boot-2.1.x/jobs/build/badge["Build Status", link="https://ci.spring.io/teams/spring-boot/pipelines/spring-boot-2.1.x?groups=Build"] image:https://badges.gitter.im/Join Chat.svg["Chat",link="https://gitter.im/spring-projects/spring-boot?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge"]
:docs: https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference :docs: https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference
Spring Boot makes it easy to create Spring-powered, production-grade applications and Spring Boot helps you to create Spring-powered, production-grade applications and
services with absolute minimum fuss. It takes an opinionated view of the Spring platform services with absolute minimum fuss. It takes an opinionated view of the Spring platform
so that new and existing users can quickly get to the bits they need. so that new and existing users can quickly get to the bits they need.
@ -163,7 +163,7 @@ There are a number of modules in Spring Boot, here is a quick overview:
The main library providing features that support the other parts of Spring Boot, The main library providing features that support the other parts of Spring Boot,
these include: these include:
* The `SpringApplication` class, providing static convenience methods that make it easy * The `SpringApplication` class, providing static convenience methods that can be used
to write a stand-alone Spring Application. Its sole job is to create and refresh an to write a stand-alone Spring Application. Its sole job is to create and refresh an
appropriate Spring `ApplicationContext` appropriate Spring `ApplicationContext`
* Embedded web applications with a choice of container (Tomcat, Jetty or Undertow) * Embedded web applications with a choice of container (Tomcat, Jetty or Undertow)
@ -190,14 +190,14 @@ Starters are a set of convenient dependency descriptors that you can include in
your application. You get a one-stop-shop for all the Spring and related technology your application. You get a one-stop-shop for all the Spring and related technology
that you need without having to hunt through sample code and copy paste loads of that you need without having to hunt through sample code and copy paste loads of
dependency descriptors. For example, if you want to get started using Spring and JPA for dependency descriptors. For example, if you want to get started using Spring and JPA for
database access just include the `spring-boot-starter-data-jpa` dependency in your database access include the `spring-boot-starter-data-jpa` dependency in your
project, and you are good to go. project, and you are good to go.
=== spring-boot-cli === spring-boot-cli
The Spring command line application compiles and runs Groovy source, making it super The Spring command line application compiles and runs Groovy source, allowing you to
easy to write the absolute minimum of code to get an application running. Spring CLI write the absolute minimum of code to get an application running. Spring CLI
can also watch files, automatically recompiling and restarting when they change. can also watch files, automatically recompiling and restarting when they change.
@ -261,7 +261,7 @@ The https://spring.io/[spring.io] site contains several guides that show how to
Boot step-by-step: Boot step-by-step:
* https://spring.io/guides/gs/spring-boot/[Building an Application with Spring Boot] is a * https://spring.io/guides/gs/spring-boot/[Building an Application with Spring Boot] is a
very basic guide that shows you how to create a simple application, run it and add some very basic guide that shows you how to create an application, run it and add some
management services. management services.
* https://spring.io/guides/gs/actuator-service/[Building a RESTful Web Service with Spring * https://spring.io/guides/gs/actuator-service/[Building a RESTful Web Service with Spring
Boot Actuator] is a guide to creating a REST web service and also shows how the server Boot Actuator] is a guide to creating a REST web service and also shows how the server

@ -8,7 +8,7 @@ https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#production
covers the features in more detail. covers the features in more detail.
== Enabling the Actuator == Enabling the Actuator
The simplest way to enable the features is to add a dependency to the The recommended way to enable the features is to add a dependency to the
`spring-boot-starter-actuator` '`Starter`'. To add the actuator to a Maven-based project, `spring-boot-starter-actuator` '`Starter`'. To add the actuator to a Maven-based project,
add the following '`Starter`' dependency: add the following '`Starter`' dependency:

@ -12,7 +12,7 @@ However, it is possible to <<configuration-metadata-additional-metadata,write pa
[[configuration-metadata-format]] [[configuration-metadata-format]]
=== Metadata Format === Metadata Format
Configuration metadata files are located inside jars under `META-INF/spring-configuration-metadata.json`. Configuration metadata files are located inside jars under `META-INF/spring-configuration-metadata.json`.
They use a simple JSON format with items categorized under either "`groups`" or "`properties`" and additional values hints categorized under "hints", as shown in the following example: 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]
---- ----
@ -736,7 +736,7 @@ This dependency ensures that the additional metadata is available when the annot
The processor picks up both classes and methods that are annotated with `@ConfigurationProperties`. The processor picks up both classes and methods that are annotated with `@ConfigurationProperties`.
The Javadoc for field values within configuration classes is used to populate the `description` attribute. The Javadoc for field values within configuration classes is used to populate the `description` attribute.
NOTE: You should only use simple text with `@ConfigurationProperties` field Javadoc, since they are not processed before being added to the JSON. NOTE: You should only use plain text with `@ConfigurationProperties` field Javadoc, since they are not processed before being added to the JSON.
Properties are discovered through the presence of standard getters and setters with special handling for collection types (that is detected even if only a getter is present). Properties are discovered through the presence of standard getters and setters with special handling for collection types (that is detected even if only a getter is present).
The annotation processor also supports the use of the `@Data`, `@Getter`, and `@Setter` lombok annotations. The annotation processor also supports the use of the `@Data`, `@Getter`, and `@Setter` lombok annotations.

@ -26,7 +26,7 @@ It minimizes divergence between development and production environments.
Ideally, your application, like a Spring Boot executable jar, has everything that it needs to run packaged within it. Ideally, your application, like a Spring Boot executable jar, has everything that it needs to run packaged within it.
In this section, we look at what it takes to get the <<getting-started.adoc#getting-started-first-application, simple application that we developed>> in the "`Getting Started`" section up and running in the Cloud. In this section, we look at what it takes to get the <<getting-started.adoc#getting-started-first-application, application that we developed>> in the "`Getting Started`" section up and running in the Cloud.
@ -227,7 +227,7 @@ The options include:
* AWS Container Registry * AWS Container Registry
Each has different features and pricing models. Each has different features and pricing models.
In this document, we describe only the simplest option: AWS Elastic Beanstalk. In this document, we describe to approach using AWS Elastic Beanstalk.
@ -399,7 +399,7 @@ Then deploy with `mvn appengine:deploy` (if you need to authenticate first, the
== Installing Spring Boot Applications == Installing Spring Boot Applications
In addition to running Spring Boot applications by using `java -jar`, it is also possible to make fully executable applications for Unix systems. In addition to running Spring Boot applications by using `java -jar`, it is also possible to make fully executable applications for Unix systems.
A fully executable jar can be executed like any other executable binary or it can be <<deployment-service,registered with `init.d` or `systemd`>>. A fully executable jar can be executed like any other executable binary or it can be <<deployment-service,registered with `init.d` or `systemd`>>.
This makes it very easy to install and manage Spring Boot applications in common production environments. This helps when installing and managing Spring Boot applications in common production environments.
CAUTION: Fully executable jars work by embedding an extra script at the front of the file. CAUTION: Fully executable jars work by embedding an extra script at the front of the file.
Currently, some tools do not accept this format, so you may not always be able to use this technique. Currently, some tools do not accept this format, so you may not always be able to use this technique.
@ -740,7 +740,7 @@ The following environment properties are supported with the default script:
| The explicit location of the jar file, in case the script is being used to launch a jar that it is not actually embedded. | The explicit location of the jar file, in case the script is being used to launch a jar that it is not actually embedded.
| `DEBUG` | `DEBUG`
| If not empty, sets the `-x` flag on the shell process, making it easy to see the logic in the script. | If not empty, sets the `-x` flag on the shell process, allowing you to see the logic in the script.
| `STOP_WAIT_TIME` | `STOP_WAIT_TIME`
| The time in seconds to wait when stopping the application before forcing a shutdown (`60` by default). | The time in seconds to wait when stopping the application before forcing a shutdown (`60` by default).

@ -13,7 +13,7 @@ We then walk you through building your first Spring Boot application, discussing
[[getting-started-introducing-spring-boot]] [[getting-started-introducing-spring-boot]]
== Introducing Spring Boot == Introducing Spring Boot
Spring Boot makes it easy to create stand-alone, production-grade Spring-based Applications that you can run. Spring Boot helps you to create stand-alone, production-grade Spring-based Applications that you can run.
We take an opinionated view of the Spring platform and third-party libraries, so that you can get started with minimum fuss. We take an opinionated view of the Spring platform and third-party libraries, so that you can get started with minimum fuss.
Most Spring Boot applications need very little Spring configuration. Most Spring Boot applications need very little Spring configuration.
@ -252,7 +252,7 @@ Get SDKMAN! from https://sdkman.io and install Spring Boot by using the followin
Spring Boot v{spring-boot-version} Spring Boot v{spring-boot-version}
---- ----
If you develop features for the CLI and want easy access to the version you built, use the following commands: 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,quotes,attributes"]
---- ----
@ -416,7 +416,7 @@ If you manually installed the CLI, follow the <<getting-started-manual-cli-insta
[[getting-started-first-application]] [[getting-started-first-application]]
== Developing Your First Spring Boot Application == Developing Your First Spring Boot Application
This section describes how to develop a simple "`Hello World!`" web application that highlights some of Spring Boot's key features. This section describes how to develop a small "`Hello World!`" web application that highlights some of Spring Boot's key features.
We use Maven to build this project, since most IDEs support it. We use Maven to build this project, since most IDEs support it.
[TIP] [TIP]
@ -626,7 +626,7 @@ Spring Boot still does its best to auto-configure your application.
[[getting-started-first-application-main-method]] [[getting-started-first-application-main-method]]
==== The "`main`" Method ==== The "`main`" Method
The final part of our application is the `main` method. The final part of our application is the `main` method.
This is just a standard method that follows the Java convention for an application entry point. This is a standard method that follows the Java convention for an application entry point.
Our main method delegates to Spring Boot's `SpringApplication` class by calling `run`. Our main method delegates to Spring Boot's `SpringApplication` class by calling `run`.
`SpringApplication` bootstraps our application, starting Spring, which, in turn, starts the auto-configured Tomcat web server. `SpringApplication` bootstraps our application, starting Spring, which, in turn, starts the auto-configured Tomcat web server.
We need to pass `Example.class` as an argument to the `run` method to tell `SpringApplication` which is the primary Spring component. We need to pass `Example.class` as an argument to the `run` method to tell `SpringApplication` which is the primary Spring component.

@ -40,7 +40,7 @@ The following example registers `ProjectConstraintViolationFailureAnalyzer`:
com.example.ProjectConstraintViolationFailureAnalyzer com.example.ProjectConstraintViolationFailureAnalyzer
---- ----
NOTE: If you need access to the `BeanFactory` or the `Environment`, your `FailureAnalyzer` can simply implement `BeanFactoryAware` or `EnvironmentAware` respectively. NOTE: If you need access to the `BeanFactory` or the `Environment`, your `FailureAnalyzer` can implement `BeanFactoryAware` or `EnvironmentAware` respectively.
@ -417,7 +417,7 @@ Many Spring Boot starters include default embedded containers.
* For reactive stack applications, the `spring-boot-starter-webflux` includes Reactor Netty by including `spring-boot-starter-reactor-netty`, but you can use `spring-boot-starter-tomcat`, `spring-boot-starter-jetty`, or `spring-boot-starter-undertow` instead. * For reactive stack applications, the `spring-boot-starter-webflux` includes Reactor Netty by including `spring-boot-starter-reactor-netty`, but you can use `spring-boot-starter-tomcat`, `spring-boot-starter-jetty`, or `spring-boot-starter-undertow` instead.
When switching to a different HTTP server, you need to exclude the default dependencies in addition to including the one you need. When switching to a different HTTP server, you need to exclude the default dependencies in addition to including the one you need.
Spring Boot provides separate starters for HTTP servers to help make this process as easy as possible. To help with this process, Spring Boot provides a separate starter for each of the supported HTTP servers.
The following Maven example shows how to exclude Tomcat and include Jetty for Spring MVC: The following Maven example shows how to exclude Tomcat and include Jetty for Spring MVC:
@ -1020,7 +1020,7 @@ The `ObjectMapper` (or `XmlMapper` for Jackson XML converter) instance (created
Spring Boot also has some features to make it easier to customize this behavior. Spring Boot also has some features to make it easier to customize this behavior.
You can configure the `ObjectMapper` and `XmlMapper` instances by using the environment. You can configure the `ObjectMapper` and `XmlMapper` instances by using the environment.
Jackson provides an extensive suite of simple on/off features that can be used to configure various aspects of its processing. Jackson provides an extensive suite of on/off features that can be used to configure various aspects of its processing.
These features are described in six enums (in Jackson) that map onto properties in the environment: These features are described in six enums (in Jackson) that map onto properties in the environment:
|=== |===
@ -1281,7 +1281,7 @@ This ensures efficient sharing of resources for the server receiving requests an
== Logging == Logging
Spring Boot has no mandatory logging dependency, except for the Commons Logging API, which is typically provided by Spring Framework's `spring-jcl` module. Spring Boot has no mandatory logging dependency, except for the Commons Logging API, which is typically provided by Spring Framework's `spring-jcl` module.
To use https://logback.qos.ch[Logback], you need to include it and `spring-jcl` on the classpath. To use https://logback.qos.ch[Logback], you need to include it and `spring-jcl` on the classpath.
The simplest way to do that is through the starters, which all depend on `spring-boot-starter-logging`. The recommended way to do that is through the starters, which all depend on `spring-boot-starter-logging`.
For a web application, you need only `spring-boot-starter-web`, since it depends transitively on the logging starter. 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: If you use Maven, the following dependency adds logging for you:
@ -1395,7 +1395,7 @@ Spring Boot supports https://logging.apache.org/log4j/2.x[Log4j 2] for logging c
If you use the starters for assembling dependencies, you have to exclude Logback and then include log4j 2 instead. If you use the starters for assembling dependencies, you have to exclude Logback and then include log4j 2 instead.
If you do not use the starters, you need to provide (at least) `spring-jcl` in addition to Log4j 2. If you do not use the starters, you need to provide (at least) `spring-jcl` in addition to Log4j 2.
The simplest path is probably through the starters, even though it requires some jiggling with excludes. The recommended path is through the starters, even though it requires some jiggling with excludes.
The following example shows how to set up the starters in Maven: 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,quotes,attributes"]
@ -1733,8 +1733,7 @@ See {spring-boot-autoconfigure-module-code}/orm/jpa/HibernateJpaAutoConfiguratio
Hibernate {hibernate-docs}#caching[second-level cache] can be configured for a range of cache providers. Hibernate {hibernate-docs}#caching[second-level cache] can be configured for a range of cache providers.
Rather than configuring Hibernate to lookup the cache provider again, it is better to provide the one that is available in the context whenever possible. Rather than configuring Hibernate to lookup the cache provider again, it is better to provide the one that is available in the context whenever possible.
If you're using JCache, this is pretty easy. To do this with JCache, first make sure that `org.hibernate:hibernate-jcache` is available on the classpath.
First, make sure that `org.hibernate:hibernate-jcache` is available on the classpath.
Then, add a `HibernatePropertiesCustomizer` bean as shown in the following example: Then, add a `HibernatePropertiesCustomizer` bean as shown in the following example:
[source,java,indent=0] [source,java,indent=0]
@ -1765,10 +1764,9 @@ Spring Boot auto-configuration switches off its entity manager in the presence o
[[howto-use-two-entity-managers]] [[howto-use-two-entity-managers]]
=== Use Two EntityManagers === Use Two EntityManagers
Even if the default `EntityManagerFactory` works fine, you need to define a new one. Even if the default `EntityManagerFactory` works fine, you need to define a new one, otherwise the presence of the second bean of that type switches off the default.
Otherwise, the presence of the second bean of that type switches off the default. You can use the `EntityManagerBuilder` provided by Spring Boot to help you to create one.
To make it easy to do, you can use the convenient `EntityManagerBuilder` provided by Spring Boot. Alternatively, you can use the `LocalContainerEntityManagerFactoryBean` directly from Spring ORM, as shown in the following example:
Alternatively, you can just the `LocalContainerEntityManagerFactoryBean` directly from Spring ORM, as shown in the following example:
[source,java,indent=0,subs="verbatim,quotes,attributes"] [source,java,indent=0,subs="verbatim,quotes,attributes"]
---- ----
@ -2158,7 +2156,7 @@ Overriding the error page with your own depends on the templating technology tha
For example, if you use Thymeleaf, you can add an `error.html` template. For example, if you use Thymeleaf, you can add an `error.html` template.
If you use FreeMarker, you can add an `error.ftl` template. If you use FreeMarker, you can add an `error.ftl` template.
In general, you need a `View` that resolves with a name of `error` or a `@Controller` that handles the `/error` path. In general, you need a `View` that resolves with a name of `error` or a `@Controller` that handles the `/error` path.
Unless you replaced some of the default configuration, you should find a `BeanNameViewResolver` in your `ApplicationContext`, so a `@Bean` named `error` would be a simple way of doing that. Unless you replaced some of the default configuration, you should find a `BeanNameViewResolver` in your `ApplicationContext`, so a `@Bean` named `error` would be one way of doing that.
See {spring-boot-autoconfigure-module-code}/web/servlet/error/ErrorMvcAutoConfiguration.java[`ErrorMvcAutoConfiguration`] for more options. See {spring-boot-autoconfigure-module-code}/web/servlet/error/ErrorMvcAutoConfiguration.java[`ErrorMvcAutoConfiguration`] for more options.
See also the section on "`<<boot-features-error-handling, Error Handling>>`" for details of how to register handlers in the servlet container. See also the section on "`<<boot-features-error-handling, Error Handling>>`" for details of how to register handlers in the servlet container.
@ -2731,8 +2729,7 @@ TIP: Take a look at Spring Boot's sample applications for a {spring-boot-code}/s
[[howto-convert-an-existing-application-to-spring-boot]] [[howto-convert-an-existing-application-to-spring-boot]]
=== Convert an Existing Application to Spring Boot === Convert an Existing Application to Spring Boot
For a non-web application, it should be easy to convert an existing Spring application to a Spring Boot application. To convert an existing non-web Spring application to a Spring Boot application, replace the code that creates your `ApplicationContext` and replace it with calls to `SpringApplication` or `SpringApplicationBuilder`.
To do so, throw away the code that creates your `ApplicationContext` and replace it with calls to `SpringApplication` or `SpringApplicationBuilder`.
Spring MVC web applications are generally amenable to first creating a deployable war application and then migrating it later to an executable war or jar. Spring MVC web applications are generally amenable to first creating a deployable war application and then migrating it later to an executable war or jar.
See the https://spring.io/guides/gs/convert-jar-to-war/[Getting Started Guide on Converting a jar to a war]. See the https://spring.io/guides/gs/convert-jar-to-war/[Getting Started Guide on Converting a jar to a war].
@ -2767,7 +2764,7 @@ If you have other features in your application (for instance, using other servle
* A `@Bean` of type `Servlet` or `ServletRegistrationBean` installs that bean in the container as if it were a `<servlet/>` and `<servlet-mapping/>` in `web.xml`. * A `@Bean` of type `Servlet` or `ServletRegistrationBean` installs that bean in the container as if it were a `<servlet/>` and `<servlet-mapping/>` in `web.xml`.
* A `@Bean` of type `Filter` or `FilterRegistrationBean` behaves similarly (as a `<filter/>` and `<filter-mapping/>`). * A `@Bean` of type `Filter` or `FilterRegistrationBean` behaves similarly (as a `<filter/>` and `<filter-mapping/>`).
* An `ApplicationContext` in an XML file can be added through an `@ImportResource` in your `Application`. * An `ApplicationContext` in an XML file can be added through an `@ImportResource` in your `Application`.
Alternatively, simple cases where annotation configuration is heavily used already can be recreated in a few lines as `@Bean` definitions. Alternatively, cases where annotation configuration is heavily used already can be recreated in a few lines as `@Bean` definitions.
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: 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:
@ -2871,7 +2868,7 @@ You can do so by adding a `WEB-INF/weblogic.xml` file with the following content
=== Use Jedis Instead of Lettuce === Use Jedis Instead of Lettuce
By default, the Spring Boot starter (`spring-boot-starter-data-redis`) uses https://github.com/lettuce-io/lettuce-core/[Lettuce]. By default, the Spring Boot starter (`spring-boot-starter-data-redis`) uses https://github.com/lettuce-io/lettuce-core/[Lettuce].
You need to exclude that dependency and include the https://github.com/xetorthio/jedis/[Jedis] one instead. You need to exclude that dependency and include the https://github.com/xetorthio/jedis/[Jedis] one instead.
Spring Boot manages these dependencies to help make this process as easy as possible. Spring Boot manages both of these dependencies so you can switch to Jedis without specifying a version.
The following example shows how to do so in Maven: The following example shows how to do so in Maven:

@ -13,7 +13,7 @@ Auditing, health, and metrics gathering can also be automatically applied to you
[[production-ready-enabling]] [[production-ready-enabling]]
== Enabling Production-ready Features == Enabling Production-ready Features
The {spring-boot-code}/spring-boot-project/spring-boot-actuator[`spring-boot-actuator`] module provides all of Spring Boot's production-ready features. The {spring-boot-code}/spring-boot-project/spring-boot-actuator[`spring-boot-actuator`] module provides all of Spring Boot's production-ready features.
The simplest way to enable the features is to add a dependency to the `spring-boot-starter-actuator` '`Starter`'. The recommended way to enable the features is to add a dependency on the `spring-boot-starter-actuator` '`Starter`'.
.Definition of Actuator .Definition of Actuator
**** ****
@ -1962,7 +1962,7 @@ You can also add any number of `tag=KEY:VALUE` query parameters to the end of th
==== ====
The reported measurements are the _sum_ of the statistics of all meters matching the meter name and any tags that have been applied. The reported measurements are the _sum_ of the statistics of all meters matching the meter name and any tags that have been applied.
So in the example above, the returned "Value" statistic is the sum of the maximum memory footprints of "Code Cache", "Compressed Class Space", and "Metaspace" areas of the heap. So in the example above, the returned "Value" statistic is the sum of the maximum memory footprints of "Code Cache", "Compressed Class Space", and "Metaspace" areas of the heap.
If you just wanted to see the maximum size for the "Metaspace", you could add an additional `tag=id:Metaspace`, i.e. `/actuator/metrics/jvm.memory.max?tag=area:nonheap&tag=id:Metaspace`. If you only wanted to see the maximum size for the "Metaspace", you could add an additional `tag=id:Metaspace`, i.e. `/actuator/metrics/jvm.memory.max?tag=area:nonheap&tag=id:Metaspace`.
==== ====

@ -20,7 +20,7 @@ See _<<getting-started.adoc#getting-started-installing-the-cli>>_ in the "`Getti
[[cli-using-the-cli]] [[cli-using-the-cli]]
== Using the CLI == Using the CLI
Once you have installed the CLI, you can run it by typing `spring` and pressing Enter at the command line. 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 simple help screen is displayed, as follows: If you run `spring` without any arguments, a help screen is displayed, as follows:
[indent=0,subs="verbatim,quotes,attributes"] [indent=0,subs="verbatim,quotes,attributes"]
---- ----

@ -226,7 +226,7 @@ The context can be injected by implementing `ApplicationContextAware` or, if the
[[boot-features-web-environment]] [[boot-features-web-environment]]
=== Web Environment === Web Environment
A `SpringApplication` attempts to create the right type of `ApplicationContext` on your behalf. A `SpringApplication` attempts to create the right type of `ApplicationContext` on your behalf.
The algorithm used to determine a `WebApplicationType` is fairly simple: The algorithm used to determine a `WebApplicationType` is the following:
* If Spring MVC is present, an `AnnotationConfigServletWebServerApplicationContext` is used * If Spring MVC is present, an `AnnotationConfigServletWebServerApplicationContext` is used
* If Spring MVC is not present and Spring WebFlux is present, an `AnnotationConfigReactiveWebServerApplicationContext` is used * If Spring MVC is not present and Spring WebFlux is present, an `AnnotationConfigReactiveWebServerApplicationContext` is used
@ -275,7 +275,7 @@ This lets you also inject single application arguments by using the `@Value` ann
If you need to run some specific code once the `SpringApplication` has started, you can implement the `ApplicationRunner` or `CommandLineRunner` interfaces. If you need to run some specific code once the `SpringApplication` has started, you can implement the `ApplicationRunner` or `CommandLineRunner` interfaces.
Both interfaces work in the same way and offer a single `run` method, which is called just before `SpringApplication.run(...)` completes. Both interfaces work in the same way and offer a single `run` method, which is called just before `SpringApplication.run(...)` completes.
The `CommandLineRunner` interfaces provides access to application arguments as a simple string array, whereas the `ApplicationRunner` uses the `ApplicationArguments` interface discussed earlier. The `CommandLineRunner` interfaces provides access to application arguments as a string array, whereas the `ApplicationRunner` uses the `ApplicationArguments` interface discussed earlier.
The following example shows a `CommandLineRunner` with a `run` method: The following example shows a `CommandLineRunner` with a `run` method:
[source,java,indent=0] [source,java,indent=0]
@ -658,7 +658,7 @@ If the `development`, `production` and `eu-central` profiles are *not* enabled,
[NOTE] [NOTE]
==== ====
`spring.profiles` can therefore contain a simple profile name (for example `production`) or a profile expression. `spring.profiles` can therefore contain a profile name (for example `production`) or a profile expression.
A profile expression allows for more complicated profile logic to be expressed, for example `production & (eu-central | eu-west)`. A profile expression allows for more complicated profile logic to be expressed, for example `production & (eu-central | eu-west)`.
Check the {spring-framework-docs}core.html#beans-definition-profiles-java[reference guide] for more details. Check the {spring-framework-docs}core.html#beans-definition-profiles-java[reference guide] for more details.
==== ====
@ -1190,7 +1190,7 @@ These are:
The default unit is milliseconds and can be overridden using `@DurationUnit` as illustrated in the sample above. The default unit is milliseconds and can be overridden using `@DurationUnit` as illustrated in the sample above.
TIP: If you are upgrading from a previous version that is simply using `Long` to express the duration, make sure to define the unit (using `@DurationUnit`) if it isn't milliseconds alongside the switch to `Duration`. TIP: If you are upgrading from a previous version that is using `Long` to express the duration, make sure to define the unit (using `@DurationUnit`) if it isn't milliseconds alongside the switch to `Duration`.
Doing so gives a transparent upgrade path while supporting a much richer format. Doing so gives a transparent upgrade path while supporting a much richer format.
@ -1224,7 +1224,7 @@ These are:
The default unit is bytes and can be overridden using `@DataSizeUnit` as illustrated in the sample above. The default unit is bytes and can be overridden using `@DataSizeUnit` as illustrated in the sample above.
TIP: If you are upgrading from a previous version that is simply using `Long` to express the size, make sure to define the unit (using `@DataSizeUnit`) if it isn't bytes alongsidethe switch to `DataSize`. TIP: If you are upgrading from a previous version that is using `Long` to express the size, make sure to define the unit (using `@DataSizeUnit`) if it isn't bytes alongsidethe switch to `DataSize`.
Doing so gives a transparent upgrade path while supporting a much richer format. Doing so gives a transparent upgrade path while supporting a much richer format.
@ -1754,7 +1754,7 @@ If you attempt to do so, making changes to the configuration file results in an
The `<springProfile>` tag lets you optionally include or exclude sections of configuration based on the active Spring profiles. The `<springProfile>` tag lets you optionally include or exclude sections of configuration based on the active Spring profiles.
Profile sections are supported anywhere within the `<configuration>` element. Profile sections are supported anywhere within the `<configuration>` element.
Use the `name` attribute to specify which profile accepts the configuration. Use the `name` attribute to specify which profile accepts the configuration.
The `<springProfile>` tag can contain a simple profile name (for example `staging`) or a profile expression. The `<springProfile>` tag can contain a profile name (for example `staging`) or a profile expression.
A profile expression allows for more complicated profile logic to be expressed, for example `production & (eu-central | eu-west)`. A profile expression allows for more complicated profile logic to be expressed, for example `production & (eu-central | eu-west)`.
Check the {spring-framework-docs}core.html#beans-definition-profiles-java[reference guide] for more details. Check the {spring-framework-docs}core.html#beans-definition-profiles-java[reference guide] for more details.
The following listing shows three sample profiles: The following listing shows three sample profiles:
@ -1873,7 +1873,7 @@ If you have not yet developed a Spring Boot web application, you can follow the
[[boot-features-spring-mvc]] [[boot-features-spring-mvc]]
=== The "`Spring Web MVC Framework`" === The "`Spring Web MVC Framework`"
The {spring-framework-docs}web.html#mvc[Spring Web MVC framework] (often referred to as simply "`Spring MVC`") is a rich "`model view controller`" web framework. The {spring-framework-docs}web.html#mvc[Spring Web MVC framework] (often referred to as "`Spring MVC`") is a rich "`model view controller`" web framework.
Spring MVC lets you create special `@Controller` or `@RestController` beans to handle incoming HTTP requests. Spring MVC lets you create special `@Controller` or `@RestController` beans to handle incoming HTTP requests.
Methods in your controller are mapped to HTTP by using `@RequestMapping` annotations. Methods in your controller are mapped to HTTP by using `@RequestMapping` annotations.
@ -2120,7 +2120,7 @@ If you understand the caveats and would still like your application to use suffi
spring.mvc.pathmatch.use-suffix-pattern=true spring.mvc.pathmatch.use-suffix-pattern=true
---- ----
Alternatively, rather than open all suffix patterns, it's more secure to just support registered suffix patterns: Alternatively, rather than open all suffix patterns, it's more secure to only support registered suffix patterns:
[source,properties,indent=0,subs="verbatim,quotes,attributes"] [source,properties,indent=0,subs="verbatim,quotes,attributes"]
---- ----
@ -2953,7 +2953,7 @@ https://oauth.net/2/[OAuth2] is a widely used authorization framework that is su
[[boot-features-security-oauth2-client]] [[boot-features-security-oauth2-client]]
==== Client ==== Client
If you have `spring-security-oauth2-client` on your classpath, you can take advantage of some auto-configuration to make it easy to set up an OAuth2/Open ID Connect clients. If you have `spring-security-oauth2-client` on your classpath, you can take advantage of some auto-configuration to set up an OAuth2/Open ID Connect clients.
This configuration makes use of the properties under `OAuth2ClientProperties`. This configuration makes use of the properties under `OAuth2ClientProperties`.
The same properties are applicable to both servlet and reactive applications. The same properties are applicable to both servlet and reactive applications.
@ -3267,8 +3267,8 @@ The `spring-boot-starter-data-jpa` POM provides a quick way to get started.
It provides the following key dependencies: It provides the following key dependencies:
* Hibernate: One of the most popular JPA implementations. * Hibernate: One of the most popular JPA implementations.
* Spring Data JPA: Makes it easy to implement JPA-based repositories. * Spring Data JPA: Helps you to implement JPA-based repositories.
* Spring ORMs: Core ORM support from the Spring Framework. * Spring ORM: Core ORM support from the Spring Framework.
TIP: We do not go into too many details of JPA or {spring-data}[Spring Data] here. TIP: We do not go into too many details of JPA or {spring-data}[Spring Data] here.
You can follow the https://spring.io/guides/gs/accessing-data-jpa/["`Accessing Data with JPA`"] guide from https://spring.io and read the {spring-data-jpa}[Spring Data JPA] and https://hibernate.org/orm/documentation/[Hibernate] reference documentation. You can follow the https://spring.io/guides/gs/accessing-data-jpa/["`Accessing Data with JPA`"] guide from https://spring.io and read the {spring-data-jpa}[Spring Data JPA] and https://hibernate.org/orm/documentation/[Hibernate] reference documentation.
@ -4288,7 +4288,7 @@ Spring Boot auto-configures the cache infrastructure as long as caching support
NOTE: Check the {spring-framework-docs}integration.html#cache[relevant section] of the Spring Framework reference for more details. NOTE: Check the {spring-framework-docs}integration.html#cache[relevant section] of the Spring Framework reference for more details.
In a nutshell, adding caching to an operation of your service is as easy as adding the relevant annotation to its method, as shown in the following example: In a nutshell, to add caching to an operation of your service add the relevant annotation to its method, as shown in the following example:
[source,java,indent=0] [source,java,indent=0]
---- ----
@ -5025,12 +5025,12 @@ Spring Boot auto-configures the required `KafkaStreamsConfiguration` bean as lon
Enabling Kafka Streams means that the application id and bootstrap servers must be set. Enabling Kafka Streams means that the application id and bootstrap servers must be set.
The former can be configured using `spring.kafka.streams.application-id`, defaulting to `spring.application.name` if not set. The former can be configured using `spring.kafka.streams.application-id`, defaulting to `spring.application.name` if not set.
The latter can be set globally or specifically overridden just for streams. The latter can be set globally or specifically overridden only for streams.
Several additional properties are available using dedicated properties; other arbitrary Kafka properties can be set using the `spring.kafka.streams.properties` namespace. Several additional properties are available using dedicated properties; other arbitrary Kafka properties can be set using the `spring.kafka.streams.properties` namespace.
See also <<boot-features-kafka-extra-props>> for more information. See also <<boot-features-kafka-extra-props>> for more information.
To use the factory bean, simply wire `StreamsBuilder` into your `@Bean` as shown in the following example: To use the factory bean, wire `StreamsBuilder` into your `@Bean` as shown in the following example:
[source,java,indent=0] [source,java,indent=0]
---- ----
@ -5231,7 +5231,7 @@ For instance, the following service triggers the validation of the first argumen
[[boot-features-email]] [[boot-features-email]]
== Sending Email == Sending Email
The Spring Framework provides an easy abstraction for sending email by using the `JavaMailSender` interface, and Spring Boot provides auto-configuration for it as well as a starter module. The Spring Framework provides an abstraction for sending email by using the `JavaMailSender` interface, and Spring Boot provides auto-configuration for it as well as a starter module.
TIP: See the {spring-framework-docs}integration.html#mail[reference documentation] for a detailed explanation of how you can use `JavaMailSender`. TIP: See the {spring-framework-docs}integration.html#mail[reference documentation] for a detailed explanation of how you can use `JavaMailSender`.
@ -7185,7 +7185,7 @@ Make sure that configuration keys are documented by adding field javadoc for eac
} }
---- ----
NOTE: You should only use simple text with `@ConfigurationProperties` field Javadoc, since they are not processed before being added to the JSON. NOTE: You should only use plain text with `@ConfigurationProperties` field Javadoc, since they are not processed before being added to the JSON.
Here are some rules we follow internally to make sure descriptions are consistent: Here are some rules we follow internally to make sure descriptions are consistent:

@ -423,7 +423,7 @@ The actual contents of those classes, such as nested configuration classes or be
[[using-boot-spring-beans-and-dependency-injection]] [[using-boot-spring-beans-and-dependency-injection]]
== Spring Beans and Dependency Injection == Spring Beans and Dependency Injection
You are free to use any of the standard Spring Framework techniques to define your beans and their injected dependencies. You are free to use any of the standard Spring Framework techniques to define your beans and their injected dependencies.
For simplicity, we often find that using `@ComponentScan` (to find your beans) and using `@Autowired` (to do constructor injection) works well. We often find that using `@ComponentScan` (to find your beans) and using `@Autowired` (to do constructor injection) works well.
If you structure your code as suggested above (locating your application class in a root package), you can add `@ComponentScan` without any arguments. If you structure your code as suggested above (locating your application class in a root package), you can add `@ComponentScan` without any arguments.
All of your application components (`@Component`, `@Service`, `@Repository`, `@Controller` etc.) are automatically registered as Spring Beans. All of your application components (`@Component`, `@Service`, `@Repository`, `@Controller` etc.) are automatically registered as Spring Beans.
@ -538,7 +538,7 @@ In this example, `Application` is just like any other Spring Boot application ex
[[using-boot-running-your-application]] [[using-boot-running-your-application]]
== Running Your Application == Running Your Application
One of the biggest advantages of packaging your application as a jar and using an embedded HTTP server is that you can run your application as you would any other. One of the biggest advantages of packaging your application as a jar and using an embedded HTTP server is that you can run your application as you would any other.
Debugging Spring Boot applications is also easy. The sample applies to debugging Spring Boot applications.
You do not need any special IDE plugins or extensions. You do not need any special IDE plugins or extensions.
NOTE: This section only covers jar based packaging. NOTE: This section only covers jar based packaging.
@ -548,7 +548,7 @@ If you choose to package your application as a war file, you should refer to you
[[using-boot-running-from-an-ide]] [[using-boot-running-from-an-ide]]
=== Running from an IDE === Running from an IDE
You can run a Spring Boot application from your IDE as a simple Java application. You can run a Spring Boot application from your IDE as a Java application.
However, you first need to import your project. However, you first need to import your project.
Import steps vary depending on your IDE and build system. Import steps vary depending on your IDE and build system.
Most IDEs can import Maven projects directly. Most IDEs can import Maven projects directly.
@ -624,7 +624,7 @@ You might also want to use the `JAVA_OPTS` operating system environment variable
[[using-boot-hot-swapping]] [[using-boot-hot-swapping]]
=== Hot Swapping === Hot Swapping
Since Spring Boot applications are just plain Java applications, JVM hot-swapping should work out of the box. Since Spring Boot applications are plain Java applications, JVM hot-swapping should work out of the box.
JVM hot swapping is somewhat limited with the bytecode that it can replace. JVM hot swapping is somewhat limited with the bytecode that it can replace.
For a more complete solution, https://jrebel.com/software/jrebel/[JRebel] can be used. For a more complete solution, https://jrebel.com/software/jrebel/[JRebel] can be used.

@ -4,7 +4,7 @@ Spring Boot Starters are a set of convenient dependency descriptors that you can
in your application. You get a one-stop-shop for all the Spring and related technology in your application. You get a one-stop-shop for all the Spring and related technology
that you need without having to hunt through sample code and copy paste loads of that you need without having to hunt through sample code and copy paste loads of
dependency descriptors. For example, if you want to get started using Spring and dependency descriptors. For example, if you want to get started using Spring and
JPA for database access just include the `spring-boot-starter-data-jpa` dependency in JPA for database access include the `spring-boot-starter-data-jpa` dependency in
your project, and you are good to go. your project, and you are good to go.
For complete details see the For complete details see the
@ -12,7 +12,7 @@ https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#using-boot
== Community Contributions == Community Contributions
If you create a starter for a technology that is not already in the standard list we can If you create a starter for a technology that is not already in the standard list we can
list it here. Just send a pull request for this page. list it here. To ask us to do so, please open a pull request that updates this page.
WARNING: While the WARNING: While the
https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#using-boot-starter[reference documentation] https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#using-boot-starter[reference documentation]

@ -4,7 +4,7 @@
When you apply the {dependency-management-plugin}[`io.spring.dependency-management`] plugin, Spring Boot's plugin will automatically <<reacting-to-other-plugins-dependency-management,import the `spring-boot-dependencies` bom>> from the version of Spring Boot that you are using. When you apply the {dependency-management-plugin}[`io.spring.dependency-management`] plugin, Spring Boot's plugin will automatically <<reacting-to-other-plugins-dependency-management,import the `spring-boot-dependencies` bom>> from the version of Spring Boot that you are using.
This provides a similar dependency management experience to the one that's enjoyed by Maven users. This provides a similar dependency management experience to the one that's enjoyed by Maven users.
For example, it allows you to omit version numbers when declaring dependencies that are managed in the bom. For example, it allows you to omit version numbers when declaring dependencies that are managed in the bom.
To make use of this functionality, simply declare dependencies in the usual way but omit the version number: To make use of this functionality, declare dependencies in the usual way but omit the version number:
[source,groovy,indent=0,subs="verbatim",role="primary"] [source,groovy,indent=0,subs="verbatim",role="primary"]
.Groovy .Groovy

@ -13,7 +13,7 @@ abstraction is supported by many caching libraries, including:
* Simple provider based on `ConcurrentHashMap` * Simple provider based on `ConcurrentHashMap`
* Generic provider based on `org.springframework.Cache` bean definition(s) * Generic provider based on `org.springframework.Cache` bean definition(s)
The sample defines a simple `CountryService` that caches countries by ISO code. When The sample defines a `CountryService` that caches countries by ISO code. When
the application starts a client invokes the service with a random code every 500ms. the application starts a client invokes the service with a random code every 500ms.
You can look at the `/metrics` endpoint to review the cache statistics if your chosen You can look at the `/metrics` endpoint to review the cache statistics if your chosen
caching provider is supported. caching provider is supported.
@ -22,7 +22,7 @@ caching provider is supported.
== Using the JSR-107 annotations == Using the JSR-107 annotations
The sample uses Spring's cache annotation. If you want to use the JSR-107 annotations The sample uses Spring's cache annotation. If you want to use the JSR-107 annotations
instead, simply add the `javax.cache:cache-api` dependency to the project. No further instead, add the `javax.cache:cache-api` dependency to the project. No further
configuration is necessary. configuration is necessary.
NOTE: You can use the JSR-107 annotations with _any_ cache provider; a JSR-107 NOTE: You can use the JSR-107 annotations with _any_ cache provider; a JSR-107
@ -61,7 +61,7 @@ of the library that you want to use.
=== EhCache 2.x === EhCache 2.x
Simply add the `net.sf.ehcache:ehcache` dependency to the project. Since there is a Add the `net.sf.ehcache:ehcache` dependency to the project. Since there is a
default `ehcache.xml` configuration file at the root of the classpath, default `ehcache.xml` configuration file at the root of the classpath,
it is automatically used to configure the underlying `CacheManager`. it is automatically used to configure the underlying `CacheManager`.
Note that EhCache 3 uses a different format and doesn't default to `ehcache.xml` Note that EhCache 3 uses a different format and doesn't default to `ehcache.xml`
@ -118,7 +118,7 @@ TIP: Run sample cache application using Redis with
=== Caffeine === Caffeine
Simply add the `com.github.ben-manes.caffeine:caffeine` dependency to enable support Add the `com.github.ben-manes.caffeine:caffeine` dependency to enable support
for Caffeine. You can customize how caches are created in different ways, see for Caffeine. You can customize how caches are created in different ways, see
`application.properties` for an example and the documentation for more details. `application.properties` for an example and the documentation for more details.

@ -1,6 +1,6 @@
= Spring Boot Couchbase Sample = Spring Boot Couchbase Sample
This sample demonstrates how you can store a simple document using Spring Data Couchbase. This sample demonstrates how you can store a document using Spring Data Couchbase.
The sample expects couchbase to run on your machine with a bucket named `default` and The sample expects couchbase to run on your machine with a bucket named `default` and
no password. You can customize these settings in `application.properties`. no password. You can customize these settings in `application.properties`.

@ -1,6 +1,6 @@
= Spring Boot Neo4j Sample = Spring Boot Neo4j Sample
This sample demonstrates the integration of Neo4j with a simple entity. It This sample demonstrates the integration of Neo4j with an entity. It
expects a Neo4j instance running on `localhost`. If your neo4j instance expects a Neo4j instance running on `localhost`. If your neo4j instance
requires authentication, update `application.properties` with your credentials: requires authentication, update `application.properties` with your credentials:

Loading…
Cancel
Save