@ -16,4 +16,4 @@ NOTE: The https://github.com/paketo-buildpacks/spring-boot[Paketo Spring Boot bu
NOTE: In order to achieve reproducible builds and container image caching, Buildpacks can manipulate the application resources metadata (such as the file "last modified" information).
You should ensure that your application does not rely on that metadata at runtime.
Spring Boot can use that information when serving static resources, but this can be disabled with configprop:spring.web.resources.cache.use-last-modified[]
Spring Boot can use that information when serving static resources, but this can be disabled with configprop:spring.web.resources.cache.use-last-modified[].
==== Connecting to Elasticsearch Using REST clients
Elasticsearch ships two different REST clients] that you can use to query a cluster: the https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/java-rest-low.html[low-level client] from the `org.elasticsearch.client:elasticsearch-rest-client` module and the https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/index.html[Java API client] from the `co.elastic.clients:elasticsearch-java` module.
Elasticsearch ships two different REST clients that you can use to query a cluster: the https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/java-rest-low.html[low-level client] from the `org.elasticsearch.client:elasticsearch-rest-client` module and the https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/index.html[Java API client] from the `co.elastic.clients:elasticsearch-java` module.
Additionally, Spring Boot provides support for a reactive client from the `org.springframework.data:spring-data-elasticsearch` module.
By default, the clients will target `http://localhost:9200`.
You can use `spring.elasticsearch.*` properties to further tune how the clients are configured, as shown in the following example:
@ -384,7 +384,7 @@ If you add your own `@Bean` of type `CassandraTemplate`, it replaces the default
[[data.nosql.cassandra.repositories]]
==== Spring Data Cassandra Repositories
Spring Data includes basic repository support for Cassandra.
Currently, this is more limited than the JPA repositories discussed earlier and needs to annotate finder methods with `@Query`.
Currently, this is more limited than the JPA repositories discussed earlier and needs `@Query` annotated finder methods.
TIP: For complete details of Spring Data Cassandra, see the https://docs.spring.io/spring-data/cassandra/docs/[reference documentation].
@ -414,7 +414,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:
For instance, the following configuration changes the timeout to open a new `Bucket` and enables SSL support:
@ -8,7 +8,7 @@ The {spring-framework}[Spring Framework] provides extensive support for working
[[data.sql.datasource]]
=== Configure a DataSource
Java's `javax.sql.DataSource` interface provides a standard method of working with database connections.
Traditionally, a 'DataSource' uses a `URL` along with some credentials to establish a database connection.
Traditionally, a `DataSource` uses a `URL` along with some credentials to establish a database connection.
TIP: See <<howto#howto.data-access.configure-custom-datasource,the "`How-to`" section>> for more advanced examples, typically to take full control over the configuration of the DataSource.
All Cloud Foundry properties are prefixed with `vcap`.
You can use `vcap` properties to access application information (such as the public URL of the application) and service information (such as database credentials).
See the {spring-boot-module-api}/cloud/CloudFoundryVcapEnvironmentPostProcessor.html['`CloudFoundryVcapEnvironmentPostProcessor`'] Javadoc for complete details.
See the {spring-boot-module-api}/cloud/CloudFoundryVcapEnvironmentPostProcessor.html[`CloudFoundryVcapEnvironmentPostProcessor`] Javadoc for complete details.
TIP: The https://github.com/pivotal-cf/java-cfenv/[Java CFEnv] project is a better fit for tasks such as configuring a DataSource.
@ -412,4 +412,4 @@ You can deploy the app (for example, with a Maven plugin) by adding the project
</plugin>
----
Then deploy with `mvn appengine:deploy` (if you need to authenticate first, the build fails).
Then deploy with `mvn appengine:deploy` (you need to authenticate first, otherwise the build fails).
If you work in a company that develops shared libraries, or if you work on an open-source or commercial library, you might want to develop your own auto-configuration.
Auto-configuration classes can be bundled in external jars and still be picked-up by Spring Boot.
Auto-configuration classes can be bundled in external jars and still be pickedup by Spring Boot.
Auto-configuration can be associated to a "`starter`" that provides the auto-configuration code as well as the typical libraries that you would use with it.
We first cover what you need to know to build your own auto-configuration and then we move on to the <<features#features.developing-auto-configuration.custom-starter,typical steps required to create a custom starter>>.
@ -37,7 +37,7 @@ TIP: You can add comments to the imports file using the `#` character.
NOTE: Auto-configurations must be loaded _only_ by being named in the imports file.
Make sure that they are defined in a specific package space and that they are never the target of component scanning.
Furthermore, auto-configuration classes should not enable component scanning to find additional components.
Specific ``@Import``s should be used instead.
Specific `@Import` annotations should be used instead.
If your configuration needs to be applied in a specific order, you can use the `before`, `beforeName`, `after` and `afterName` attributes on the {spring-boot-autoconfigure-module-code}/AutoConfiguration.java[`@AutoConfiguration`] annotation or the dedicated {spring-boot-autoconfigure-module-code}/AutoConfigureBefore.java[`@AutoConfigureBefore`] and {spring-boot-autoconfigure-module-code}/AutoConfigureAfter.java[`@AutoConfigureAfter`] annotations.
For example, if you provide web-specific configuration, your class may need to be applied after `WebMvcAutoConfiguration`.
@ -207,7 +207,7 @@ If "acme" has several flavors, options or optional features, then it is better t
Besides, you have the ability to craft a starter that provides an opinion about those optional dependencies.
At the same time, others can rely only on the `autoconfigure` module and craft their own starter with different opinions.
If the auto-configuration is relatively straightforward and does not have optional feature, merging the two modules in the starter is definitely an option.
If the auto-configuration is relatively straightforward and does not have optional features, merging the two modules in the starter is definitely an option.
@ -542,7 +542,7 @@ Log4j2 supports a number of https://logging.apache.org/log4j/2.x/manual/configur
For example, the `log4j2.skipJansi` system property can be used to configure if the `ConsoleAppender` will try to use a https://github.com/fusesource/jansi[Jansi] output stream on Windows.
All system properties that are loaded after the Log4j2 initialization can be obtained from the Spring `Environment`.
For example, you could add `log4j2.skipJansi=false` to your `application.properties` file to have the `ConsoleAppender` use a Jansi on Windows.
For example, you could add `log4j2.skipJansi=false` to your `application.properties` file to have the `ConsoleAppender` use Jansi on Windows.
NOTE: The Spring `Environment` is only considered when system properties and OS environment variables do not contain the value being loaded.
@ -64,7 +64,7 @@ The `spring.profiles.include` property can be used to add active profiles on top
The `SpringApplication` entry point also has a Java API for setting additional profiles.
See the `setAdditionalProfiles()` method in {spring-boot-module-api}/SpringApplication.html[SpringApplication].
For example, when an application with the following properties is run, the common and local profiles will be activated even when it runs using the --spring.profiles.active switch:
For example, when an application with the following properties is run, the common and local profiles will be activated even when it runs using the `--spring.profiles.active` switch:
`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:
To use it, add `@ExtendWith(OutputCaptureExtension.class)` and inject `CapturedOutput` as an argument to your test class constructor or test method as follows:
include::code:MyOutputCaptureTests[]
@ -950,7 +950,7 @@ Instead, such errors can be detected through the returned `ResponseEntity` and i
TIP: Spring Framework 5.0 provides a new `WebTestClient` that works for <<features#features.testing.spring-boot-applications.spring-webflux-tests, WebFlux integration tests>> and both <<features#features.testing.spring-boot-applications.with-running-server, WebFlux and MVC end-to-end testing>>.
It provides a fluent API for assertions, unlike `TestRestTemplate`.
It is recommended, but not mandatory, to use the Apache HTTP Client (version 4.3.2 or better).
It is recommended, but not mandatory, to use the Apache HTTP Client (version 5.1 or better).
If you have that on your classpath, the `TestRestTemplate` responds by configuring the client appropriately.
If you do use Apache's HTTP client, some additional test-friendly features are enabled:
@ -35,7 +35,7 @@ If you use OSX Homebrew, try `brew install maven`.
Ubuntu users can run `sudo apt-get install maven`.
Windows users with https://chocolatey.org/[Chocolatey] can run `choco install maven` from an elevated (administrator) prompt.
Spring Boot dependencies use the `org.springframework.boot` `groupId`.
Spring Boot dependencies use the `org.springframework.boot` group id.
Typically, your Maven POM file inherits from the `spring-boot-starter-parent` project and declares dependencies to one or more <<using#using.build-systems.starters,"`Starters`">>.
Spring Boot also provides an optional <<build-tool-plugins#build-tool-plugins.maven, Maven plugin>> to create executable jars.
@ -23,7 +23,7 @@ For more info about Spring Batch, see the {spring-batch}[Spring Batch project pa
Spring Batch auto-configuration is enabled by adding `@EnableBatchProcessing` to one of your `@Configuration` classes.
If a single `Job` is found in the application context, it is executed on startup (see {spring-boot-autoconfigure-module-code}/batch/JobLauncherApplicationRunner.java[`JobLauncherApplicationRunner`] for details).
If multiple ``Job``s are found, the job that should be executed must be specified using configprop:spring.batch.job.name[].
If multiple `Job` beans are found, the job that should be executed must be specified using configprop:spring.batch.job.name[].
To disable running a `Job` found in the application content, set the configprop:spring.batch.job.enabled[] to `false.`
@ -226,7 +226,7 @@ If your schema requires mixed-case identifiers, define a custom `CamelCaseToUnde
include::code:spring/MyHibernateConfiguration[]
If you prefer to use Hibernate 5's default instead, set the following property:
If you prefer to use Hibernate's default instead, set the following property:
[indent=0,properties,subs="verbatim"]
----
@ -319,7 +319,7 @@ The most explicit way to do that is to use the standard Spring Data `+@EnableJpa
There are also flags (`+spring.data.*.repositories.enabled+` and `+spring.data.*.repositories.type+`) that you can use to switch the auto-configured repositories on and off in external configuration.
Doing so is useful, for instance, in case you want to switch off the Mongo repositories and still use the auto-configured `MongoTemplate`.
The same obstacle and the same features exist for other auto-configured Spring Data repository types (Elasticsearch, Solr, and others).
The same obstacle and the same features exist for other auto-configured Spring Data repository types (Elasticsearch, Redis, and others).
To work with them, change the names of the annotations and flags accordingly.
Spring Boot will auto-detect which `ClientHttpConnector` to use to drive `WebClient`, depending on the libraries available on the application classpath.
For now, Reactor Netty, Jetty RS client, Apache HttpClient, and the JDK's HttpClient are supported.
For now, Reactor Netty, Jetty ReactiveStream client, Apache HttpClient, and the JDK's HttpClient are supported.
The `spring-boot-starter-webflux` starter depends on `io.projectreactor.netty:reactor-netty` by default, which brings both server and client implementations.
If you choose to use Jetty as a reactive server instead, you should add a dependency on the Jetty Reactive HTTP client library, `org.eclipse.jetty:jetty-reactive-httpclient`.
@ -18,7 +18,7 @@ The curated list contains all the Spring modules that you can use with Spring Bo
The list is available as a standard Bills of Materials (`spring-boot-dependencies`) that can be used with both <<using#using.build-systems.maven,Maven>> and <<using#using.build-systems.gradle,Gradle>>.
WARNING: Each release of Spring Boot is associated with a base version of the Spring Framework.
We **highly** recommend that you not specify its version.
We **highly** recommend that you do not specify its version.
@ -119,8 +119,8 @@ You can register multiple OAuth2 clients and providers under the `spring.securit
For OpenID Connect providers that support https://openid.net/specs/openid-connect-discovery-1_0.html[OpenID Connect discovery], the configuration can be further simplified.
The provider needs to be configured with an `issuer-uri` which is the URI that it asserts as its Issuer Identifier.
For example, if the `issuer-uri` provided is "https://example.com", then an `OpenID Provider Configuration Request` will be made to "https://example.com/.well-known/openid-configuration".
The result is expected to be an `OpenID Provider Configuration Response`.
For example, if the `issuer-uri` provided is "https://example.com", then an "OpenID Provider Configuration Request" will be made to "https://example.com/.well-known/openid-configuration".
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`: