mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-15 01:07:30 +08:00
Update Spring Framework links
Closes gh-36241
This commit is contained in:
parent
8ac2e3e38f
commit
d29f7a88b4
@ -293,6 +293,10 @@ tasks.withType(org.asciidoctor.gradle.jvm.AbstractAsciidoctorTask) {
|
||||
}
|
||||
doFirst {
|
||||
def versionConstraints = dependencyVersions.versionConstraints
|
||||
def toAntoraVersion = version -> {
|
||||
String formatted = version.split("\\.").take(2).join('.')
|
||||
return version.endsWith("-SNAPSHOT") ? formatted + "-SNAPSHOT" : formatted
|
||||
}
|
||||
def securityVersion = versionConstraints["org.springframework.security:spring-security-core"]
|
||||
if (securityVersion.endsWith("-SNAPSHOT")) {
|
||||
securityVersion = securityVersion.substring(0, securityVersion.length() - "-SNAPSHOT".length())
|
||||
@ -314,6 +318,7 @@ tasks.withType(org.asciidoctor.gradle.jvm.AbstractAsciidoctorTask) {
|
||||
"spring-data-r2dbc-version": versionConstraints["org.springframework.data:spring-data-r2dbc"],
|
||||
"spring-data-rest-version": versionConstraints["org.springframework.data:spring-data-rest-core"],
|
||||
"spring-framework-version": versionConstraints["org.springframework:spring-core"],
|
||||
"spring-framework-version-antora": toAntoraVersion(versionConstraints["org.springframework:spring-core"]),
|
||||
"spring-graphql-version": versionConstraints["org.springframework.graphql:spring-graphql"],
|
||||
"spring-integration-version": versionConstraints["org.springframework.integration:spring-integration-core"],
|
||||
"spring-kafka-version": versionConstraints["org.springframework.kafka:spring-kafka"],
|
||||
|
@ -747,7 +747,7 @@ Auto-configuration enables the instrumentation of all requests handled by Spring
|
||||
By default, metrics are generated with the name, `http.server.requests`.
|
||||
You can customize the name by setting the configprop:management.observations.http.server.requests.name[] property.
|
||||
|
||||
See the {spring-framework-docs}/integration.html#integration.observability.http-server.servlet[Spring Framework reference documentation for more information on produced observations].
|
||||
See the {spring-framework-docs}/integration/observability.html#observability.http-server.servlet[Spring Framework reference documentation for more information on produced observations].
|
||||
|
||||
To add to the default tags, provide a `@Bean` that extends `DefaultServerRequestObservationConvention` from the `org.springframework.http.server.observation` package.
|
||||
To replace the default tags, provide a `@Bean` that implements `ServerRequestObservationConvention`.
|
||||
@ -767,7 +767,7 @@ Auto-configuration enables the instrumentation of all requests handled by Spring
|
||||
By default, metrics are generated with the name, `http.server.requests`.
|
||||
You can customize the name by setting the configprop:management.observations.http.server.requests.name[] property.
|
||||
|
||||
See the {spring-framework-docs}/integration.html#integration.observability.http-server.reactive[Spring Framework reference documentation for more information on produced observations].
|
||||
See the {spring-framework-docs}/integration/observability.html#observability.http-server.reactive[Spring Framework reference documentation for more information on produced observations].
|
||||
|
||||
To add to the default tags, provide a `@Bean` that extends `DefaultServerRequestObservationConvention` from the `org.springframework.http.server.reactive.observation` package.
|
||||
To replace the default tags, provide a `@Bean` that implements `ServerRequestObservationConvention`.
|
||||
@ -822,7 +822,7 @@ You can also manually apply the customizers responsible for this instrumentation
|
||||
By default, metrics are generated with the name, `http.client.requests`.
|
||||
You can customize the name by setting the configprop:management.observations.http.client.requests.name[] property.
|
||||
|
||||
See the {spring-framework-docs}/integration.html#integration.observability.http-client[Spring Framework reference documentation for more information on produced observations].
|
||||
See the {spring-framework-docs}/integration/observability.html#observability.http-client[Spring Framework reference documentation for more information on produced observations].
|
||||
|
||||
To customize the tags when using `RestTemplate`, provide a `@Bean` that implements `ClientRequestObservationConvention` from the `org.springframework.http.client.observation` package.
|
||||
To customize the tags when using `WebClient`, provide a `@Bean` that implements `ClientRequestObservationConvention` from the `org.springframework.web.reactive.function.client` package.
|
||||
|
@ -82,7 +82,7 @@
|
||||
:spring-data-rest-api: https://docs.spring.io/spring-data/rest/docs/{spring-data-rest-version}/api/org/springframework/data/rest
|
||||
:spring-framework: https://spring.io/projects/spring-framework
|
||||
:spring-framework-api: https://docs.spring.io/spring-framework/docs/{spring-framework-version}/javadoc-api/org/springframework
|
||||
:spring-framework-docs: https://docs.spring.io/spring-framework/docs/{spring-framework-version}/reference/html
|
||||
:spring-framework-docs: https://docs.spring.io/spring-framework/reference/{spring-framework-version-antora}
|
||||
:spring-graphql: https://spring.io/projects/spring-graphql
|
||||
:spring-graphql-api: https://docs.spring.io/spring-graphql/docs/{spring-graphql-version}/api/
|
||||
:spring-graphql-docs: https://docs.spring.io/spring-graphql/docs/{spring-graphql-version}/reference/html/
|
||||
|
@ -1,7 +1,7 @@
|
||||
[[features.aop]]
|
||||
== Aspect-Oriented Programming
|
||||
Spring Boot provides auto-configuration for aspect-oriented programming (AOP).
|
||||
You can learn more about AOP with Spring in the {spring-framework-docs}/core.html#aop[Spring Framework reference documentation].
|
||||
You can learn more about AOP with Spring in the {spring-framework-docs}/core/aop-api.html[Spring Framework reference documentation].
|
||||
|
||||
By default, Spring Boot's auto-configuration configures Spring AOP to use CGLib proxies.
|
||||
To use JDK proxies instead, set `configprop:spring.aop.proxy-target-class` to `false`.
|
||||
|
@ -136,7 +136,7 @@ This condition will not match for applications that are run with an embedded web
|
||||
|
||||
[[features.developing-auto-configuration.condition-annotations.spel-conditions]]
|
||||
==== SpEL Expression Conditions
|
||||
The `@ConditionalOnExpression` annotation lets configuration be included based on the result of a {spring-framework-docs}/core.html#expressions[SpEL expression].
|
||||
The `@ConditionalOnExpression` annotation lets configuration be included based on the result of a {spring-framework-docs}/core/expressions.html[SpEL expression].
|
||||
|
||||
NOTE: Referencing a bean in the expression will cause that bean to be initialized very early in context refresh processing.
|
||||
As a result, the bean won't be eligible for post-processing (such as configuration properties binding) and its state may be incomplete.
|
||||
|
@ -3,7 +3,7 @@
|
||||
https://kotlinlang.org[Kotlin] is a statically-typed language targeting the JVM (and other platforms) which allows writing concise and elegant code while providing {kotlin-docs}java-interop.html[interoperability] with existing libraries written in Java.
|
||||
|
||||
Spring Boot provides Kotlin support by leveraging the support in other Spring projects such as Spring Framework, Spring Data, and Reactor.
|
||||
See the {spring-framework-docs}/languages.html#kotlin[Spring Framework Kotlin support documentation] for more information.
|
||||
See the {spring-framework-docs}/languages/kotlin.html[Spring Framework Kotlin support documentation] for more information.
|
||||
|
||||
The easiest way to start with Spring Boot and Kotlin is to follow https://spring.io/guides/tutorials/spring-boot-kotlin/[this comprehensive tutorial].
|
||||
You can create new Kotlin projects by using https://start.spring.io/#!language=kotlin[start.spring.io].
|
||||
|
@ -435,7 +435,7 @@ Profile sections are supported anywhere within the `<configuration>` element.
|
||||
Use the `name` attribute to specify which profile accepts the configuration.
|
||||
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)`.
|
||||
Check the {spring-framework-docs}/core.html#beans-definition-profiles-java[Spring Framework reference guide] for more details.
|
||||
Check the {spring-framework-docs}/core/beans/environment.html#beans-definition-profiles-java[Spring Framework reference guide] for more details.
|
||||
The following listing shows three sample profiles:
|
||||
|
||||
[source,xml,subs="verbatim",indent=0]
|
||||
@ -500,7 +500,7 @@ Profile sections are supported anywhere within the `<Configuration>` element.
|
||||
Use the `name` attribute to specify which profile accepts the configuration.
|
||||
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)`.
|
||||
Check the {spring-framework-docs}/core.html#beans-definition-profiles-java[Spring Framework reference guide] for more details.
|
||||
Check the {spring-framework-docs}/core/beans/environment.html#beans-definition-profiles-java[Spring Framework reference guide] for more details.
|
||||
The following listing shows three sample profiles:
|
||||
|
||||
[source,xml,subs="verbatim",indent=0]
|
||||
|
@ -356,7 +356,7 @@ TIP: If you want to know on which HTTP port the application is running, get the
|
||||
=== Application Startup tracking
|
||||
During the application startup, the `SpringApplication` and the `ApplicationContext` perform many tasks related to the application lifecycle,
|
||||
the beans lifecycle or even processing application events.
|
||||
With {spring-framework-api}/core/metrics/ApplicationStartup.html[`ApplicationStartup`], Spring Framework {spring-framework-docs}/core.html#context-functionality-startup[allows you to track the application startup sequence with `StartupStep` objects].
|
||||
With {spring-framework-api}/core/metrics/ApplicationStartup.html[`ApplicationStartup`], Spring Framework {spring-framework-docs}/core/beans/context-introduction.html#context-functionality-startup[allows you to track the application startup sequence with `StartupStep` objects].
|
||||
This data can be collected for profiling purposes, or just to have a better understanding of an application startup process.
|
||||
|
||||
You can choose an `ApplicationStartup` implementation when setting up the `SpringApplication` instance.
|
||||
|
@ -35,7 +35,7 @@ To use the vintage engine, add a dependency on `junit-vintage-engine`, as shown
|
||||
The `spring-boot-starter-test` "`Starter`" (in the `test` `scope`) contains the following provided libraries:
|
||||
|
||||
* https://junit.org/junit5/[JUnit 5]: The de-facto standard for unit testing Java applications.
|
||||
* {spring-framework-docs}/testing.html#integration-testing[Spring Test] & Spring Boot Test: Utilities and integration test support for Spring Boot applications.
|
||||
* {spring-framework-docs}/testing/integration.html[Spring Test] & Spring Boot Test: Utilities and integration test support for Spring Boot applications.
|
||||
* https://assertj.github.io/doc/[AssertJ]: A fluent assertion library.
|
||||
* https://github.com/hamcrest/JavaHamcrest[Hamcrest]: A library of matcher objects (also known as constraints or predicates).
|
||||
* https://site.mockito.org/[Mockito]: A Java mocking framework.
|
||||
@ -59,7 +59,7 @@ It is useful to be able to perform integration testing without requiring deploym
|
||||
The Spring Framework includes a dedicated test module for such integration testing.
|
||||
You can declare a dependency directly to `org.springframework:spring-test` or use the `spring-boot-starter-test` "`Starter`" to pull it in transitively.
|
||||
|
||||
If you have not used the `spring-test` module before, you should start by reading the {spring-framework-docs}/testing.html#testing[relevant section] of the Spring Framework reference documentation.
|
||||
If you have not used the `spring-test` module before, you should start by reading the {spring-framework-docs}/testing.html[relevant section] of the Spring Framework reference documentation.
|
||||
|
||||
|
||||
|
||||
@ -198,13 +198,13 @@ include::code:MyApplicationArgumentTests[]
|
||||
==== Testing With a Mock Environment
|
||||
By default, `@SpringBootTest` does not start the server but instead sets up a mock environment for testing web endpoints.
|
||||
|
||||
With Spring MVC, we can query our web endpoints using {spring-framework-docs}/testing.html#spring-mvc-test-framework[`MockMvc`] or `WebTestClient`, as shown in the following example:
|
||||
With Spring MVC, we can query our web endpoints using {spring-framework-docs}/testing/spring-mvc-test-framework.html[`MockMvc`] or `WebTestClient`, as shown in the following example:
|
||||
|
||||
include::code:MyMockMvcTests[]
|
||||
|
||||
TIP: If you want to focus only on the web layer and not start a complete `ApplicationContext`, consider <<features#features.testing.spring-boot-applications.spring-mvc-tests,using `@WebMvcTest` instead>>.
|
||||
|
||||
With Spring WebFlux endpoints, you can use {spring-framework-docs}/testing.html#webtestclient-tests[`WebTestClient`] as shown in the following example:
|
||||
With Spring WebFlux endpoints, you can use {spring-framework-docs}/testing/webtestclient.html[`WebTestClient`] as shown in the following example:
|
||||
|
||||
include::code:MyMockWebTestClientTests[]
|
||||
|
||||
@ -226,7 +226,7 @@ If you need to start a full running server, we recommend that you use random por
|
||||
If you use `@SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT)`, an available port is picked at random each time your test runs.
|
||||
|
||||
The `@LocalServerPort` annotation can be used to <<howto#howto.webserver.discover-port,inject the actual port used>> 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:
|
||||
For convenience, tests that need to make REST calls to the started server can additionally `@Autowire` a {spring-framework-docs}/testing/webtestclient.html[`WebTestClient`], which resolves relative links to the running server and comes with a dedicated API for verifying responses, as shown in the following example:
|
||||
|
||||
include::code:MyRandomPortWebTestClientTests[]
|
||||
|
||||
@ -419,7 +419,7 @@ TIP: If you need to register extra components, such as Jackson `Module`, you can
|
||||
|
||||
Often, `@WebFluxTest` is limited to a single controller and used in combination with the `@MockBean` annotation to provide mock implementations for required collaborators.
|
||||
|
||||
`@WebFluxTest` also auto-configures {spring-framework-docs}/testing.html#webtestclient[`WebTestClient`], which offers a powerful way to quickly test WebFlux controllers without needing to start a full HTTP server.
|
||||
`@WebFluxTest` also auto-configures {spring-framework-docs}/testing/webtestclient.html[`WebTestClient`], which offers a powerful way to quickly test WebFlux controllers without needing to start a full HTTP server.
|
||||
|
||||
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`:
|
||||
@ -558,7 +558,7 @@ Regular `@Component` and `@ConfigurationProperties` beans are not scanned when t
|
||||
TIP: A list of the auto-configuration settings that are enabled by `@DataJpaTest` can be <<test-auto-configuration#appendix.test-auto-configuration,found in the appendix>>.
|
||||
|
||||
By default, data JPA 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.
|
||||
See the {spring-framework-docs}/testing/testcontext-framework/tx.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:
|
||||
|
||||
include::code:MyNonTransactionalTests[]
|
||||
@ -590,7 +590,7 @@ Regular `@Component` and `@ConfigurationProperties` beans are not scanned when t
|
||||
TIP: A list of the auto-configurations that are enabled by `@JdbcTest` can be <<test-auto-configuration#appendix.test-auto-configuration,found in the appendix>>.
|
||||
|
||||
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.
|
||||
See the {spring-framework-docs}/testing/testcontext-framework/tx.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:
|
||||
|
||||
include::code:MyTransactionalTests[]
|
||||
@ -610,7 +610,7 @@ Only `AbstractJdbcConfiguration` subclasses are scanned when the `@DataJdbcTest`
|
||||
TIP: A list of the auto-configurations that are enabled by `@DataJdbcTest` can be <<test-auto-configuration#appendix.test-auto-configuration,found in the appendix>>.
|
||||
|
||||
By default, Data 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.
|
||||
See the {spring-framework-docs}/testing/testcontext-framework/tx.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 test class as <<features#features.testing.spring-boot-applications.autoconfigured-jdbc,shown in the JDBC example>>.
|
||||
|
||||
If you prefer your test to run against a real database, you can use the `@AutoConfigureTestDatabase` annotation in the same way as for `@DataJpaTest`.
|
||||
@ -686,7 +686,7 @@ The following example shows a typical setup for using Neo4J tests in Spring Boot
|
||||
include::code:propagation/MyDataNeo4jTests[]
|
||||
|
||||
By default, Data Neo4j 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.
|
||||
See the {spring-framework-docs}/testing/testcontext-framework/tx.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:
|
||||
|
||||
include::code:nopropagation/MyDataNeo4jTests[]
|
||||
|
@ -157,7 +157,7 @@ It tells Spring that any HTTP request with the `/` path should be mapped to the
|
||||
The `@RestController` annotation tells Spring to render the resulting string directly back to the caller.
|
||||
|
||||
TIP: The `@RestController` and `@RequestMapping` annotations are Spring MVC annotations (they are not specific to Spring Boot).
|
||||
See the {spring-framework-docs}/web.html#mvc[MVC section] in the Spring Reference Documentation for more details.
|
||||
See the {spring-framework-docs}/web/webmvc.html[MVC section] in the Spring Reference Documentation for more details.
|
||||
|
||||
|
||||
|
||||
|
@ -416,7 +416,7 @@ There are also non-standard headers, like `X-Forwarded-Host`, `X-Forwarded-Port`
|
||||
If the proxy adds the commonly used `X-Forwarded-For` and `X-Forwarded-Proto` headers, setting `server.forward-headers-strategy` to `NATIVE` is enough to support those.
|
||||
With this option, the Web servers themselves natively support this feature; you can check their specific documentation to learn about specific behavior.
|
||||
|
||||
If this is not enough, Spring Framework provides a {spring-framework-docs}/web.html#filters-forwarded-headers[ForwardedHeaderFilter] for the servlet stack and a {spring-framework-docs}/web-reactive.html#webflux-forwarded-headers[ForwardedHeaderTransformer] for the reactive stack.
|
||||
If this is not enough, Spring Framework provides a {spring-framework-docs}/web/webmvc/filters.html#filters-forwarded-headers[ForwardedHeaderFilter] for the servlet stack and a {spring-framework-docs}/web/webflux/reactive-spring.html#webflux-forwarded-headers[ForwardedHeaderTransformer] for the reactive stack.
|
||||
You can use them in your application by setting configprop:server.forward-headers-strategy[] to `FRAMEWORK`.
|
||||
|
||||
TIP: If you are using Tomcat and terminating SSL at the proxy, configprop:server.tomcat.redirect-context-root[] should be set to `false`.
|
||||
|
@ -5,7 +5,7 @@ At its core, the abstraction applies caching to methods, thus reducing the numbe
|
||||
The caching logic is applied transparently, without any interference to the invoker.
|
||||
Spring Boot auto-configures the cache infrastructure as long as caching support is enabled by using the `@EnableCaching` annotation.
|
||||
|
||||
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/cache.html[relevant section] of the Spring Framework reference for more details.
|
||||
|
||||
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:
|
||||
|
||||
@ -26,7 +26,7 @@ When you have made up your mind about the cache provider to use, please make sur
|
||||
Nearly all providers require you to explicitly configure every cache that you use in the application.
|
||||
Some offer a way to customize the default caches defined by the configprop:spring.cache.cache-names[] property.
|
||||
|
||||
TIP: It is also possible to transparently {spring-framework-docs}/integration.html#cache-annotations-put[update] or {spring-framework-docs}/integration.html#cache-annotations-evict[evict] data from the cache.
|
||||
TIP: It is also possible to transparently {spring-framework-docs}/integration/cache/annotations.html#cache-annotations-put[update] or {spring-framework-docs}/integration/cache/annotations.html#cache-annotations-evict[evict] data from the cache.
|
||||
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
== Sending Email
|
||||
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/email.html[reference documentation] for a detailed explanation of how you can use `JavaMailSender`.
|
||||
|
||||
If `spring.mail.host` and the relevant libraries (as defined by `spring-boot-starter-mail`) are available, a default `JavaMailSender` is created if none exists.
|
||||
The sender can be further customized by configuration items from the `spring.mail` namespace.
|
||||
|
@ -61,7 +61,7 @@ In addition to replacing the auto-configured builder, this also prevents any `Re
|
||||
=== WebClient
|
||||
If you have Spring WebFlux on your classpath, you can also choose to use `WebClient` to call remote REST services.
|
||||
Compared to `RestTemplate`, this client has a more functional feel and is fully reactive.
|
||||
You can learn more about the `WebClient` in the dedicated {spring-framework-docs}/web-reactive.html#webflux-client[section in the Spring Framework docs].
|
||||
You can learn more about the `WebClient` in the dedicated {spring-framework-docs}/web/webflux-webclient.html[section in the Spring Framework docs].
|
||||
|
||||
Spring Boot creates and pre-configures a `WebClient.Builder` for you.
|
||||
It is strongly advised to inject it in your components and use it to create `WebClient` instances.
|
||||
@ -93,7 +93,7 @@ Developers can override the resource configuration for Jetty and Reactor Netty b
|
||||
|
||||
If you wish to override that choice for the client, you can define your own `ClientHttpConnector` bean and have full control over the client configuration.
|
||||
|
||||
You can learn more about the {spring-framework-docs}/web-reactive.html#webflux-client-builder[`WebClient` configuration options in the Spring Framework reference documentation].
|
||||
You can learn more about the {spring-framework-docs}/web/webflux-webclient/client-builder.html[`WebClient` configuration options in the Spring Framework reference documentation].
|
||||
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
== JMS
|
||||
The `jakarta.jms.ConnectionFactory` interface provides a standard method of creating a `jakarta.jms.Connection` for interacting with a JMS broker.
|
||||
Although Spring needs a `ConnectionFactory` to work with JMS, you generally need not use it directly yourself and can instead rely on higher level messaging abstractions.
|
||||
(See the {spring-framework-docs}/integration.html#jms[relevant section] of the Spring Framework reference documentation for details.)
|
||||
(See the {spring-framework-docs}/integration/jms.html[relevant section] of the Spring Framework reference documentation for details.)
|
||||
Spring Boot also auto-configures the necessary infrastructure to send and receive messages.
|
||||
|
||||
|
||||
|
@ -5,7 +5,7 @@ It enables symmetric interaction models through async message passing over a sin
|
||||
|
||||
|
||||
The `spring-messaging` module of the Spring Framework provides support for RSocket requesters and responders, both on the client and on the server side.
|
||||
See the {spring-framework-docs}/web-reactive.html#rsocket-spring[RSocket section] of the Spring Framework reference for more details, including an overview of the RSocket protocol.
|
||||
See the {spring-framework-docs}/rsocket.html#rsocket-spring[RSocket section] of the Spring Framework reference for more details, including an overview of the RSocket protocol.
|
||||
|
||||
|
||||
|
||||
|
@ -3,9 +3,9 @@
|
||||
Spring Boot provides WebSockets auto-configuration for embedded Tomcat, Jetty, and Undertow.
|
||||
If you deploy a war file to a standalone container, Spring Boot assumes that the container is responsible for the configuration of its WebSocket support.
|
||||
|
||||
Spring Framework provides {spring-framework-docs}/web.html#websocket[rich WebSocket support] for MVC web applications that can be easily accessed through the `spring-boot-starter-websocket` module.
|
||||
Spring Framework provides {spring-framework-docs}/web/websocket.html[rich WebSocket support] for MVC web applications that can be easily accessed through the `spring-boot-starter-websocket` module.
|
||||
|
||||
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`:
|
||||
WebSocket support is also available for {spring-framework-docs}/web/webflux-websocket.html[reactive web applications] and requires to include the WebSocket API alongside `spring-boot-starter-webflux`:
|
||||
|
||||
[source,xml,indent=0,subs="verbatim"]
|
||||
----
|
||||
|
@ -157,7 +157,7 @@ include::code:MyRuntimeHints[]
|
||||
|
||||
You can then use `@ImportRuntimeHints` on any `@Configuration` class (for example your `@SpringBootApplication` annotated application class) to activate those hints.
|
||||
|
||||
If you have classes which need binding (mostly needed when serializing or deserializing JSON), you can use {spring-framework-docs}/core.html#aot-hints-register-reflection-for-binding[`@RegisterReflectionForBinding`] on any bean.
|
||||
If you have classes which need binding (mostly needed when serializing or deserializing JSON), you can use {spring-framework-docs}/core/aot.html#aot.hints.register-reflection-for-binding[`@RegisterReflectionForBinding`] on any bean.
|
||||
Most of the hints are automatically inferred, for example when accepting or returning data from a `@RestController` method.
|
||||
But when you work with `WebClient` or `RestTemplate` directly, you might need to use `@RegisterReflectionForBinding`.
|
||||
|
||||
|
@ -12,13 +12,15 @@ The annotation-based one is quite close to the Spring MVC model, as shown in the
|
||||
|
||||
include::code:MyRestController[]
|
||||
|
||||
WebFlux is part of the Spring Framework and detailed information is available in its {spring-framework-docs}/web/webflux.html[reference documentation].
|
||||
|
||||
"`WebFlux.fn`", the functional variant, separates the routing configuration from the actual handling of the requests, as shown in the following example:
|
||||
|
||||
include::code:MyRoutingConfiguration[]
|
||||
|
||||
include::code:MyUserHandler[]
|
||||
|
||||
WebFlux is part of the Spring Framework and detailed information is available in its {spring-framework-docs}/web-reactive.html#webflux-fn[reference documentation].
|
||||
"`WebFlux.fn`" is part of the Spring Framework and detailed information is available in its {spring-framework-docs}/web/webflux-functional.html[reference documentation].
|
||||
|
||||
TIP: You can define as many `RouterFunction` beans as you like to modularize the definition of the router.
|
||||
Beans can be ordered if you need to apply a precedence.
|
||||
@ -40,7 +42,7 @@ The auto-configuration adds the following features on top of Spring's defaults:
|
||||
* Configuring codecs for `HttpMessageReader` and `HttpMessageWriter` instances (described <<web#web.reactive.webflux.httpcodecs,later in this document>>).
|
||||
* Support for serving static resources, including support for WebJars (described <<web#web.servlet.spring-mvc.static-content,later in this document>>).
|
||||
|
||||
If you want to keep Spring Boot WebFlux features and you want to add additional {spring-framework-docs}/web-reactive.html#webflux-config[WebFlux configuration], you can add your own `@Configuration` class of type `WebFluxConfigurer` but *without* `@EnableWebFlux`.
|
||||
If you want to keep Spring Boot WebFlux features and you want to add additional {spring-framework-docs}/web/webflux/config.html[WebFlux configuration], you can add your own `@Configuration` class of type `WebFluxConfigurer` but *without* `@EnableWebFlux`.
|
||||
|
||||
If you want to take complete control of Spring WebFlux, you can add your own `@Configuration` annotated with `@EnableWebFlux`.
|
||||
|
||||
@ -145,7 +147,7 @@ For machine clients, it produces a JSON response with details of the error, the
|
||||
For browser clients, there is a "`whitelabel`" error handler that renders the same data in HTML format.
|
||||
You can also provide your own HTML templates to display errors (see the <<web#web.reactive.webflux.error-handling.error-pages,next section>>).
|
||||
|
||||
Before customizing error handling in Spring Boot directly, you can leverage the {spring-framework-docs}/web-reactive.html#webflux-ann-rest-exceptions[RFC 7807 Problem Details] support in Spring WebFlux.
|
||||
Before customizing error handling in Spring Boot directly, you can leverage the {spring-framework-docs}/web/webflux/ann-rest-exceptions.html[RFC 7807 Problem Details] support in Spring WebFlux.
|
||||
Spring WebFlux can produce custom error messages with the `application/problem+json` media type, like:
|
||||
|
||||
[source,json,indent=0,subs="verbatim"]
|
||||
|
@ -6,7 +6,7 @@ If you want to build servlet-based web applications, you can take advantage of S
|
||||
|
||||
[[web.servlet.spring-mvc]]
|
||||
=== The "`Spring Web MVC 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.
|
||||
The {spring-framework-docs}/web/webmvc.html[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.
|
||||
Methods in your controller are mapped to HTTP by using `@RequestMapping` annotations.
|
||||
|
||||
@ -20,7 +20,7 @@ include::code:MyRoutingConfiguration[]
|
||||
|
||||
include::code:MyUserHandler[]
|
||||
|
||||
Spring MVC is part of the core Spring Framework, and detailed information is available in the {spring-framework-docs}/web.html#mvc[reference documentation].
|
||||
Spring MVC is part of the core Spring Framework, and detailed information is available in the {spring-framework-docs}/web/webmvc.html[reference documentation].
|
||||
There are also several guides that cover Spring MVC available at https://spring.io/guides.
|
||||
|
||||
TIP: You can define as many `RouterFunction` beans as you like to modularize the definition of the router.
|
||||
@ -42,7 +42,7 @@ In addition to Spring MVC's defaults, the auto-configuration provides the follow
|
||||
* Static `index.html` support.
|
||||
* Automatic use of a `ConfigurableWebBindingInitializer` bean (covered <<features#web.servlet.spring-mvc.binding-initializer,later in this document>>).
|
||||
|
||||
If you want to keep those Spring Boot MVC customizations and make more {spring-framework-docs}/web.html#mvc[MVC customizations] (interceptors, formatters, view controllers, and other features), you can add your own `@Configuration` class of type `WebMvcConfigurer` but *without* `@EnableWebMvc`.
|
||||
If you want to keep those Spring Boot MVC customizations and make more {spring-framework-docs}/web/webmvc.html[MVC customizations] (interceptors, formatters, view controllers, and other features), you can add your own `@Configuration` class of type `WebMvcConfigurer` but *without* `@EnableWebMvc`.
|
||||
|
||||
If you want to provide custom instances of `RequestMappingHandlerMapping`, `RequestMappingHandlerAdapter`, or `ExceptionHandlerExceptionResolver`, and still keep the Spring Boot MVC customizations, you can declare a bean of type `WebMvcRegistrations` and use it to provide custom instances of those components.
|
||||
The custom instances will be subject to further initialization and configuration by Spring MVC.
|
||||
@ -186,7 +186,7 @@ See {spring-boot-autoconfigure-module-code}/web/WebProperties.java[`WebPropertie
|
||||
|
||||
[TIP]
|
||||
====
|
||||
This feature has been thoroughly described in a dedicated https://spring.io/blog/2014/07/24/spring-framework-4-1-handling-static-web-resources[blog post] and in Spring Framework's {spring-framework-docs}/web.html#mvc-config-static-resources[reference documentation].
|
||||
This feature has been thoroughly described in a dedicated https://spring.io/blog/2014/07/24/spring-framework-4-1-handling-static-web-resources[blog post] and in Spring Framework's {spring-framework-docs}/web/webmvc/mvc-config/static-resources.html[reference documentation].
|
||||
====
|
||||
|
||||
|
||||
@ -212,7 +212,7 @@ If such a file is present, it is automatically used as the favicon of the applic
|
||||
Spring MVC can map incoming HTTP requests to handlers by looking at the request path and matching it to the mappings defined in your application (for example, `@GetMapping` annotations on Controller methods).
|
||||
|
||||
Spring Boot chooses to disable suffix pattern matching by default, which means that requests like `"GET /projects/spring-boot.json"` will not be matched to `@GetMapping("/projects/spring-boot")` mappings.
|
||||
This is considered as a {spring-framework-docs}/web.html#mvc-ann-requestmapping-suffix-pattern-match[best practice for Spring MVC applications].
|
||||
This is considered as a {spring-framework-docs}/web/webmvc/mvc-controller/ann-requestmapping.html#mvc-ann-requestmapping-suffix-pattern-match[best practice for Spring MVC applications].
|
||||
This feature was mainly useful in the past for HTTP clients which did not send proper "Accept" request headers; we needed to make sure to send the correct Content Type to the client.
|
||||
Nowadays, Content Negotiation is much more reliable.
|
||||
|
||||
@ -252,7 +252,7 @@ Most standard media types are supported out-of-the-box, but you can also define
|
||||
As of Spring Framework 5.3, Spring MVC supports two strategies for matching request paths to controllers.
|
||||
By default, Spring Boot uses the `PathPatternParser` strategy.
|
||||
`PathPatternParser` is an https://spring.io/blog/2020/06/30/url-matching-with-pathpattern-in-spring-mvc[optimized implementation] but comes with some restrictions compared to the `AntPathMatcher` strategy.
|
||||
`PathPatternParser` restricts usage of {spring-framework-docs}/web.html#mvc-ann-requestmapping-uri-templates[some path pattern variants].
|
||||
`PathPatternParser` restricts usage of {spring-framework-docs}/web/webmvc/mvc-controller/ann-requestmapping.html#mvc-ann-requestmapping-uri-templates[some path pattern variants].
|
||||
It is also incompatible with configuring the `DispatcherServlet` with a path prefix (configprop:spring.mvc.servlet.path[]).
|
||||
|
||||
The strategy can be configured using the configprop:spring.mvc.pathmatch.matching-strategy[] configuration property, as shown in the following example:
|
||||
@ -319,7 +319,7 @@ TIP: The `BasicErrorController` can be used as a base class for a custom `ErrorC
|
||||
This is particularly useful if you want to add a handler for a new content type (the default is to handle `text/html` specifically and provide a fallback for everything else).
|
||||
To do so, extend `BasicErrorController`, add a public method with a `@RequestMapping` that has a `produces` attribute, and create a bean of your new type.
|
||||
|
||||
As of Spring Framework 6.0, {spring-framework-docs}/web.html#mvc-ann-rest-exceptions[RFC 7807 Problem Details] is supported.
|
||||
As of Spring Framework 6.0, {spring-framework-docs}/web/webmvc/mvc-ann-rest-exceptions.html[RFC 7807 Problem Details] is supported.
|
||||
Spring MVC can produce custom error messages with the `application/problem+json` media type, like:
|
||||
|
||||
[source,json,indent=0,subs="verbatim"]
|
||||
@ -388,7 +388,7 @@ For more complex mappings, you can also add beans that implement the `ErrorViewR
|
||||
|
||||
include::code:MyErrorViewResolver[]
|
||||
|
||||
You can also use regular Spring MVC features such as {spring-framework-docs}/web.html#mvc-exceptionhandlers[`@ExceptionHandler` methods] and {spring-framework-docs}/web.html#mvc-ann-controller-advice[`@ControllerAdvice`].
|
||||
You can also use regular Spring MVC features such as {spring-framework-docs}/web/webmvc/mvc-servlet/exceptionhandlers.html[`@ExceptionHandler` methods] and {spring-framework-docs}/web/webmvc/mvc-controller/ann-advice.html[`@ControllerAdvice`].
|
||||
The `ErrorController` then picks up any unhandled exceptions.
|
||||
|
||||
|
||||
@ -424,9 +424,9 @@ You should disable this behavior by setting `com.ibm.ws.webcontainer.invokeFlush
|
||||
==== CORS Support
|
||||
https://en.wikipedia.org/wiki/Cross-origin_resource_sharing[Cross-origin resource sharing] (CORS) is a https://www.w3.org/TR/cors/[W3C specification] implemented by https://caniuse.com/#feat=cors[most browsers] that lets you specify in a flexible way what kind of cross-domain requests are authorized, instead of using some less secure and less powerful approaches such as IFRAME or JSONP.
|
||||
|
||||
As of version 4.2, Spring MVC {spring-framework-docs}/web.html#mvc-cors[supports CORS].
|
||||
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:
|
||||
As of version 4.2, Spring MVC {spring-framework-docs}/web/webmvc-cors.html[supports CORS].
|
||||
Using {spring-framework-docs}/web/webmvc-cors.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/webmvc-cors.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:
|
||||
|
||||
include::code:MyCorsConfiguration[]
|
||||
|
||||
|
@ -103,7 +103,7 @@ This is quite useful for retrieving information from an HTTP request header and
|
||||
With Spring Boot, you can declare a `WebInterceptor` bean to have it registered with the web transport.
|
||||
|
||||
|
||||
{spring-framework-docs}/web.html#mvc-cors[Spring MVC] and {spring-framework-docs}/web-reactive.html#webflux-cors[Spring WebFlux] support CORS (Cross-Origin Resource Sharing) requests.
|
||||
{spring-framework-docs}/web/webmvc-cors.html[Spring MVC] and {spring-framework-docs}/web/webflux-cors.html[Spring WebFlux] support CORS (Cross-Origin Resource Sharing) requests.
|
||||
CORS is a critical part of the web config for GraphQL applications that are accessed from browsers using different domains.
|
||||
|
||||
Spring Boot supports many configuration properties under the `spring.graphql.cors.*` namespace; here's a short configuration sample:
|
||||
|
Loading…
Reference in New Issue
Block a user