Extract recurring asciidoc links to attributes, cleanup old doc files
This commit extract spring-related links and recurring external links into asciidoctor attributes to be used by the Antora toolchain. It notably homogenizes links to: - IETF RFCs - Java Community Process JSRs - the Java API Documentation (on the Java 17 version) - Kotlin documentations (on the Kotlinlang.org version) - the Spring Boot reference guide (on the `html` version) This commit also reworks most link attributes to follow a Project-Category-Misc syntax. For example, `spring-boot-docs` rather than `docs-spring-boot`. Finally, it makes an effort to clean up remainders from the previous documentation toolchain, namely the `docs/asciidoc` folder and `modules/ROOT/pages/attributes.adoc` file. Closes gh-26864 Closes gh-31619
This commit is contained in:
parent
4cc43b4ddc
commit
8567402969
|
|
@ -17,16 +17,73 @@ asciidoc:
|
||||||
# FIXME: the copyright is not removed
|
# FIXME: the copyright is not removed
|
||||||
# FIXME: The package is not renamed
|
# FIXME: The package is not renamed
|
||||||
chomp: 'all'
|
chomp: 'all'
|
||||||
|
fold: 'all'
|
||||||
include-java: 'example$docs-src/main/java/org/springframework/docs'
|
include-java: 'example$docs-src/main/java/org/springframework/docs'
|
||||||
spring-framework-main-code: 'https://github.com/spring-projects/spring-framework/tree/main'
|
spring-site: 'https://spring.io'
|
||||||
|
spring-site-blog: '{spring-site}/blog'
|
||||||
|
spring-site-cve: "{spring-site}/security"
|
||||||
|
spring-site-guides: '{spring-site}/guides'
|
||||||
|
spring-site-projects: '{spring-site}/projects'
|
||||||
|
spring-site-tools: "{spring-site}/tools"
|
||||||
|
spring-org: 'spring-projects'
|
||||||
|
spring-github-org: "https://github.com/{spring-org}"
|
||||||
|
spring-framework-github: "https://github.com/{spring-org}/spring-framework"
|
||||||
|
spring-framework-code: '{spring-framework-github}/tree/main'
|
||||||
|
spring-framework-issues: '{spring-framework-github}/issues'
|
||||||
|
spring-framework-wiki: '{spring-framework-github}/wiki'
|
||||||
|
# Docs
|
||||||
docs-site: 'https://docs.spring.io'
|
docs-site: 'https://docs.spring.io'
|
||||||
docs-spring: "{docs-site}/spring-framework/docs/{spring-version}"
|
spring-framework-docs-root: '{docs-site}/spring-framework/docs'
|
||||||
docs-spring-framework: '{docs-site}/spring-framework/docs/{spring-version}'
|
spring-framework-api: '{spring-framework-docs-root}/{spring-version}/javadoc-api/org/springframework'
|
||||||
api-spring-framework: '{docs-spring-framework}/javadoc-api/org/springframework'
|
spring-framework-api-kdoc: '{spring-framework-docs-root}/{spring-version}/kdoc-api'
|
||||||
docs-graalvm: 'https://www.graalvm.org/22.3/reference-manual'
|
spring-framework-reference: '{spring-framework-docs-root}/{spring-version}/reference'
|
||||||
docs-spring-boot: '{docs-site}/spring-boot/docs/current/reference'
|
#
|
||||||
|
# Other Spring portfolio projects
|
||||||
|
spring-boot-docs: '{docs-site}/spring-boot/docs/current/reference/html'
|
||||||
|
spring-boot-issues: '{spring-github-org}/spring-boot/issues'
|
||||||
|
# TODO add more projects / links or just build up on {docs-site}?
|
||||||
|
# TODO rename the below using new conventions
|
||||||
docs-spring-gemfire: '{docs-site}/spring-gemfire/docs/current/reference'
|
docs-spring-gemfire: '{docs-site}/spring-gemfire/docs/current/reference'
|
||||||
docs-spring-security: '{docs-site}/spring-security/reference'
|
docs-spring-security: '{docs-site}/spring-security/reference'
|
||||||
gh-rsocket: 'https://github.com/rsocket'
|
docs-spring-session: '{docs-site}/spring-session/reference'
|
||||||
gh-rsocket-extensions: '{gh-rsocket}/rsocket/blob/master/Extensions'
|
#
|
||||||
gh-rsocket-java: '{gh-rsocket}/rsocket-java{gh-rsocket}/rsocket-java'
|
# External projects URLs and related attributes
|
||||||
|
aspectj-site: 'https://www.eclipse.org/aspectj'
|
||||||
|
aspectj-docs: "{aspectj-site}/doc/released"
|
||||||
|
aspectj-api: "{aspectj-docs}/runtime-api"
|
||||||
|
aspectj-docs-devguide: "{aspectj-docs}/devguide"
|
||||||
|
aspectj-docs-progguide: "{aspectj-docs}/progguide"
|
||||||
|
assertj-docs: 'https://assertj.github.io/doc'
|
||||||
|
baeldung-blog: 'https://www.baeldung.com'
|
||||||
|
bean-validation-site: 'https://beanvalidation.org'
|
||||||
|
graalvm-docs: 'https://www.graalvm.org/22.3/reference-manual'
|
||||||
|
hibernate-validator-site: 'https://hibernate.org/validator/'
|
||||||
|
jackson-docs: 'https://fasterxml.github.io'
|
||||||
|
jackson-github-org: 'https://github.com/FasterXML'
|
||||||
|
java-api: 'https://docs.oracle.com/en/java/javase/17/docs/api'
|
||||||
|
java-tutorial: 'https://docs.oracle.com/javase/tutorial'
|
||||||
|
JSR: 'https://www.jcp.org/en/jsr/detail?id='
|
||||||
|
kotlin-site: 'https://kotlinlang.org'
|
||||||
|
kotlin-docs: '{kotlin-site}/docs'
|
||||||
|
kotlin-api: '{kotlin-site}/api/latest'
|
||||||
|
kotlin-coroutines-api: '{kotlin-site}/api/kotlinx.coroutines'
|
||||||
|
kotlin-github-org: 'https://github.com/Kotlin'
|
||||||
|
kotlin-issues: 'https://youtrack.jetbrains.com/issue'
|
||||||
|
reactive-streams-site: 'https://www.reactive-streams.org'
|
||||||
|
reactive-streams-spec: 'https://github.com/reactive-streams/reactive-streams-jvm/blob/master/README.md#specification'
|
||||||
|
reactor-github-org: 'https://github.com/reactor'
|
||||||
|
reactor-site: 'https://projectreactor.io'
|
||||||
|
rsocket-github-org: 'https://github.com/rsocket'
|
||||||
|
rsocket-java: '{rsocket-github-org}/rsocket-java'
|
||||||
|
rsocket-java-code: '{rsocket-java}/tree/master/'
|
||||||
|
rsocket-protocol-extensions: '{rsocket-github-org}/rsocket/tree/master/Extensions'
|
||||||
|
rsocket-site: 'https://rsocket.io'
|
||||||
|
rfc-site: 'https://datatracker.ietf.org/doc/html'
|
||||||
|
sockjs-client: 'https://github.com/sockjs/sockjs-client'
|
||||||
|
sockjs-protocol: 'https://github.com/sockjs/sockjs-protocol'
|
||||||
|
sockjs-protocol-site: "https://sockjs.github.io/sockjs-protocol"
|
||||||
|
stackoverflow-site: 'https://stackoverflow.com'
|
||||||
|
stackoverflow-questions: '{stackoverflow-site}/questions'
|
||||||
|
stackoverflow-spring-tag: "{stackoverflow-questions}/tagged/spring"
|
||||||
|
stackoverflow-spring-kotlin-tags: "{stackoverflow-spring-tag}+kotlin"
|
||||||
|
testcontainers-site: 'https://www.testcontainers.org'
|
||||||
|
|
@ -439,4 +439,4 @@
|
||||||
** xref:languages/groovy.adoc[]
|
** xref:languages/groovy.adoc[]
|
||||||
** xref:languages/dynamic.adoc[]
|
** xref:languages/dynamic.adoc[]
|
||||||
* xref:appendix.adoc[]
|
* xref:appendix.adoc[]
|
||||||
* https://github.com/spring-projects/spring-framework/wiki[Wiki]
|
* {spring-framework-wiki}[Wiki]
|
||||||
|
|
@ -8,7 +8,7 @@ within the core Spring Framework.
|
||||||
[[appendix-spring-properties]]
|
[[appendix-spring-properties]]
|
||||||
== Spring Properties
|
== Spring Properties
|
||||||
|
|
||||||
{api-spring-framework}/core/SpringProperties.html[`SpringProperties`] is a static holder
|
{spring-framework-api}/core/SpringProperties.html[`SpringProperties`] is a static holder
|
||||||
for properties that control certain low-level aspects of the Spring Framework. Users can
|
for properties that control certain low-level aspects of the Spring Framework. Users can
|
||||||
configure these properties via JVM system properties or programmatically via the
|
configure these properties via JVM system properties or programmatically via the
|
||||||
`SpringProperties.setProperty(String key, String value)` method. The latter may be
|
`SpringProperties.setProperty(String key, String value)` method. The latter may be
|
||||||
|
|
@ -25,7 +25,7 @@ The following table lists all currently supported Spring properties.
|
||||||
| `spring.beaninfo.ignore`
|
| `spring.beaninfo.ignore`
|
||||||
| Instructs Spring to use the `Introspector.IGNORE_ALL_BEANINFO` mode when calling the
|
| Instructs Spring to use the `Introspector.IGNORE_ALL_BEANINFO` mode when calling the
|
||||||
JavaBeans `Introspector`. See
|
JavaBeans `Introspector`. See
|
||||||
{api-spring-framework}++/beans/StandardBeanInfoFactory.html#IGNORE_BEANINFO_PROPERTY_NAME++[`CachedIntrospectionResults`]
|
{spring-framework-api}++/beans/StandardBeanInfoFactory.html#IGNORE_BEANINFO_PROPERTY_NAME++[`CachedIntrospectionResults`]
|
||||||
for details.
|
for details.
|
||||||
|
|
||||||
| `spring.expression.compiler.mode`
|
| `spring.expression.compiler.mode`
|
||||||
|
|
@ -36,7 +36,7 @@ xref:core/expressions/evaluation.adoc#expressions-compiler-configuration[Spring
|
||||||
| Instructs Spring to ignore operating system environment variables if a Spring
|
| Instructs Spring to ignore operating system environment variables if a Spring
|
||||||
`Environment` property -- for example, a placeholder in a configuration String -- isn't
|
`Environment` property -- for example, a placeholder in a configuration String -- isn't
|
||||||
resolvable otherwise. See
|
resolvable otherwise. See
|
||||||
{api-spring-framework}++/core/env/AbstractEnvironment.html#IGNORE_GETENV_PROPERTY_NAME++[`AbstractEnvironment`]
|
{spring-framework-api}++/core/env/AbstractEnvironment.html#IGNORE_GETENV_PROPERTY_NAME++[`AbstractEnvironment`]
|
||||||
for details.
|
for details.
|
||||||
|
|
||||||
| `spring.jdbc.getParameterType.ignore`
|
| `spring.jdbc.getParameterType.ignore`
|
||||||
|
|
@ -47,12 +47,12 @@ See the note in xref:data-access/jdbc/advanced.adoc#jdbc-batch-list[Batch Operat
|
||||||
| Instructs Spring to ignore a default JNDI environment, as an optimization for scenarios
|
| Instructs Spring to ignore a default JNDI environment, as an optimization for scenarios
|
||||||
where nothing is ever to be found for such JNDI fallback searches to begin with, avoiding
|
where nothing is ever to be found for such JNDI fallback searches to begin with, avoiding
|
||||||
the repeated JNDI lookup overhead. See
|
the repeated JNDI lookup overhead. See
|
||||||
{api-spring-framework}++/jndi/JndiLocatorDelegate.html#IGNORE_JNDI_PROPERTY_NAME++[`JndiLocatorDelegate`]
|
{spring-framework-api}++/jndi/JndiLocatorDelegate.html#IGNORE_JNDI_PROPERTY_NAME++[`JndiLocatorDelegate`]
|
||||||
for details.
|
for details.
|
||||||
|
|
||||||
| `spring.objenesis.ignore`
|
| `spring.objenesis.ignore`
|
||||||
| Instructs Spring to ignore Objenesis, not even attempting to use it. See
|
| Instructs Spring to ignore Objenesis, not even attempting to use it. See
|
||||||
{api-spring-framework}++/objenesis/SpringObjenesis.html#IGNORE_OBJENESIS_PROPERTY_NAME++[`SpringObjenesis`]
|
{spring-framework-api}++/objenesis/SpringObjenesis.html#IGNORE_OBJENESIS_PROPERTY_NAME++[`SpringObjenesis`]
|
||||||
for details.
|
for details.
|
||||||
|
|
||||||
| `spring.test.aot.processing.failOnError`
|
| `spring.test.aot.processing.failOnError`
|
||||||
|
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
// Spring Portfolio
|
|
||||||
:docs-site: https://docs.spring.io
|
|
||||||
:docs-spring-boot: {docs-site}/spring-boot/docs/current/reference
|
|
||||||
:docs-spring-gemfire: {docs-site}/spring-gemfire/docs/current/reference
|
|
||||||
:docs-spring-security: {docs-site}/spring-security/reference
|
|
||||||
// spring-asciidoctor-backends Settings
|
|
||||||
:chomp: default headers packages
|
|
||||||
:fold: all
|
|
||||||
// Spring Framework
|
|
||||||
:docs-spring-framework: {docs-site}/spring-framework/docs/{spring-version}
|
|
||||||
:api-spring-framework: {docs-spring-framework}/javadoc-api/org/springframework
|
|
||||||
:docs-java: {docdir}/../../main/java/org/springframework/docs
|
|
||||||
:docs-kotlin: {docdir}/../../main/kotlin/org/springframework/docs
|
|
||||||
:docs-resources: {docdir}/../../main/resources
|
|
||||||
:spring-framework-main-code: https://github.com/spring-projects/spring-framework/tree/main
|
|
||||||
// Third-party Links
|
|
||||||
:docs-graalvm: https://www.graalvm.org/22.3/reference-manual
|
|
||||||
:gh-rsocket: https://github.com/rsocket
|
|
||||||
:gh-rsocket-extensions: {gh-rsocket}/rsocket/blob/master/Extensions
|
|
||||||
:gh-rsocket-java: {gh-rsocket}/rsocket-java
|
|
||||||
|
|
@ -12,5 +12,5 @@ support for new custom advice types be added without changing the core framework
|
||||||
The only constraint on a custom `Advice` type is that it must implement the
|
The only constraint on a custom `Advice` type is that it must implement the
|
||||||
`org.aopalliance.aop.Advice` marker interface.
|
`org.aopalliance.aop.Advice` marker interface.
|
||||||
|
|
||||||
See the {api-spring-framework}/aop/framework/adapter/package-summary.html[`org.springframework.aop.framework.adapter`]
|
See the {spring-framework-api}/aop/framework/adapter/package-summary.html[`org.springframework.aop.framework.adapter`]
|
||||||
javadoc for further information.
|
javadoc for further information.
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ The following listing shows an example configuration:
|
||||||
|
|
||||||
Note that the target object (`businessObjectTarget` in the preceding example) must be a
|
Note that the target object (`businessObjectTarget` in the preceding example) must be a
|
||||||
prototype. This lets the `PoolingTargetSource` implementation create new instances
|
prototype. This lets the `PoolingTargetSource` implementation create new instances
|
||||||
of the target to grow the pool as necessary. See the {api-spring-framework}/aop/target/AbstractPoolingTargetSource.html[javadoc of
|
of the target to grow the pool as necessary. See the {spring-framework-api}/aop/target/AbstractPoolingTargetSource.html[javadoc of
|
||||||
`AbstractPoolingTargetSource`] and the concrete subclass you wish to use for information
|
`AbstractPoolingTargetSource`] and the concrete subclass you wish to use for information
|
||||||
about its properties. `maxSize` is the most basic and is always guaranteed to be present.
|
about its properties. `maxSize` is the most basic and is always guaranteed to be present.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ Kotlin::
|
||||||
----
|
----
|
||||||
======
|
======
|
||||||
|
|
||||||
See the {api-spring-framework}/aop/aspectj/annotation/AspectJProxyFactory.html[javadoc] for more information.
|
See the {spring-framework-api}/aop/aspectj/annotation/AspectJProxyFactory.html[javadoc] for more information.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
@AspectJ refers to a style of declaring aspects as regular Java classes annotated with
|
@AspectJ refers to a style of declaring aspects as regular Java classes annotated with
|
||||||
annotations. The @AspectJ style was introduced by the
|
annotations. The @AspectJ style was introduced by the
|
||||||
https://www.eclipse.org/aspectj[AspectJ project] as part of the AspectJ 5 release. Spring
|
{aspectj-site}[AspectJ project] as part of the AspectJ 5 release. Spring
|
||||||
interprets the same annotations as AspectJ 5, using a library supplied by AspectJ
|
interprets the same annotations as AspectJ 5, using a library supplied by AspectJ
|
||||||
for pointcut parsing and matching. The AOP runtime is still pure Spring AOP, though, and
|
for pointcut parsing and matching. The AOP runtime is still pure Spring AOP, though, and
|
||||||
there is no dependency on the AspectJ compiler or weaver.
|
there is no dependency on the AspectJ compiler or weaver.
|
||||||
|
|
|
||||||
|
|
@ -482,7 +482,7 @@ The `JoinPoint` interface provides a number of useful methods:
|
||||||
* `getSignature()`: Returns a description of the method that is being advised.
|
* `getSignature()`: Returns a description of the method that is being advised.
|
||||||
* `toString()`: Prints a useful description of the method being advised.
|
* `toString()`: Prints a useful description of the method being advised.
|
||||||
|
|
||||||
See the https://www.eclipse.org/aspectj/doc/released/runtime-api/org/aspectj/lang/JoinPoint.html[javadoc] for more detail.
|
See the {aspectj-api}/org/aspectj/lang/JoinPoint.html[javadoc] for more detail.
|
||||||
|
|
||||||
[[aop-ataspectj-advice-params-passing]]
|
[[aop-ataspectj-advice-params-passing]]
|
||||||
=== Passing Parameters to Advice
|
=== Passing Parameters to Advice
|
||||||
|
|
@ -730,7 +730,7 @@ of determining parameter names, an exception will be thrown.
|
||||||
flag for `javac`. Recommended approach on Java 8+.
|
flag for `javac`. Recommended approach on Java 8+.
|
||||||
`AspectJAdviceParameterNameDiscoverer` :: Deduces parameter names from the pointcut
|
`AspectJAdviceParameterNameDiscoverer` :: Deduces parameter names from the pointcut
|
||||||
expression, `returning`, and `throwing` clauses. See the
|
expression, `returning`, and `throwing` clauses. See the
|
||||||
{api-spring-framework}/aop/aspectj/AspectJAdviceParameterNameDiscoverer.html[javadoc]
|
{spring-framework-api}/aop/aspectj/AspectJAdviceParameterNameDiscoverer.html[javadoc]
|
||||||
for details on the algorithm used.
|
for details on the algorithm used.
|
||||||
|
|
||||||
[[aop-ataspectj-advice-params-names-explicit]]
|
[[aop-ataspectj-advice-params-names-explicit]]
|
||||||
|
|
|
||||||
|
|
@ -36,9 +36,9 @@ Kotlin::
|
||||||
|
|
||||||
The pointcut expression that forms the value of the `@Pointcut` annotation is a regular
|
The pointcut expression that forms the value of the `@Pointcut` annotation is a regular
|
||||||
AspectJ pointcut expression. For a full discussion of AspectJ's pointcut language, see
|
AspectJ pointcut expression. For a full discussion of AspectJ's pointcut language, see
|
||||||
the https://www.eclipse.org/aspectj/doc/released/progguide/index.html[AspectJ
|
the {aspectj-docs-progguide}/index.html[AspectJ
|
||||||
Programming Guide] (and, for extensions, the
|
Programming Guide] (and, for extensions, the
|
||||||
https://www.eclipse.org/aspectj/doc/released/adk15notebook/index.html[AspectJ 5
|
{aspectj-docs}/adk15notebook/index.html[AspectJ 5
|
||||||
Developer's Notebook]) or one of the books on AspectJ (such as _Eclipse AspectJ_, by Colyer
|
Developer's Notebook]) or one of the books on AspectJ (such as _Eclipse AspectJ_, by Colyer
|
||||||
et al., or _AspectJ in Action_, by Ramnivas Laddad).
|
et al., or _AspectJ in Action_, by Ramnivas Laddad).
|
||||||
|
|
||||||
|
|
@ -392,7 +392,7 @@ method that takes no parameters, whereas `(..)` matches any number (zero or more
|
||||||
The `({asterisk})` pattern matches a method that takes one parameter of any type.
|
The `({asterisk})` pattern matches a method that takes one parameter of any type.
|
||||||
`(*,String)` matches a method that takes two parameters. The first can be of any type, while the
|
`(*,String)` matches a method that takes two parameters. The first can be of any type, while the
|
||||||
second must be a `String`. Consult the
|
second must be a `String`. Consult the
|
||||||
https://www.eclipse.org/aspectj/doc/released/progguide/semantics-pointcuts.html[Language
|
{aspectj-docs-progguide}/semantics-pointcuts.html[Language
|
||||||
Semantics] section of the AspectJ Programming Guide for more information.
|
Semantics] section of the AspectJ Programming Guide for more information.
|
||||||
|
|
||||||
The following examples show some common pointcut expressions:
|
The following examples show some common pointcut expressions:
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
= Further Resources
|
= Further Resources
|
||||||
:page-section-summary-toc: 1
|
:page-section-summary-toc: 1
|
||||||
|
|
||||||
More information on AspectJ can be found on the https://www.eclipse.org/aspectj[AspectJ website].
|
More information on AspectJ can be found on the {aspectj-site}[AspectJ website].
|
||||||
|
|
||||||
_Eclipse AspectJ_ by Adrian Colyer et. al. (Addison-Wesley, 2005) provides a
|
_Eclipse AspectJ_ by Adrian Colyer et. al. (Addison-Wesley, 2005) provides a
|
||||||
comprehensive introduction and reference for the AspectJ language.
|
comprehensive introduction and reference for the AspectJ language.
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@ using Spring in accordance with the properties of the annotation". In this conte
|
||||||
"initialization" refers to newly instantiated objects (for example, objects instantiated
|
"initialization" refers to newly instantiated objects (for example, objects instantiated
|
||||||
with the `new` operator) as well as to `Serializable` objects that are undergoing
|
with the `new` operator) as well as to `Serializable` objects that are undergoing
|
||||||
deserialization (for example, through
|
deserialization (for example, through
|
||||||
https://docs.oracle.com/javase/8/docs/api/java/io/Serializable.html[readResolve()]).
|
{java-api}/java.base/java/io/Serializable.html[readResolve()]).
|
||||||
|
|
||||||
[NOTE]
|
[NOTE]
|
||||||
=====
|
=====
|
||||||
|
|
@ -168,14 +168,13 @@ Kotlin::
|
||||||
|
|
||||||
You can find more information about the language semantics of the various pointcut
|
You can find more information about the language semantics of the various pointcut
|
||||||
types in AspectJ
|
types in AspectJ
|
||||||
https://www.eclipse.org/aspectj/doc/next/progguide/semantics-joinPoints.html[in this
|
{aspectj-docs-progguide}/semantics-joinPoints.html[in this appendix] of the
|
||||||
appendix] of the https://www.eclipse.org/aspectj/doc/next/progguide/index.html[AspectJ
|
{aspectj-docs-progguide}/index.html[AspectJ Programming Guide].
|
||||||
Programming Guide].
|
|
||||||
=====
|
=====
|
||||||
|
|
||||||
For this to work, the annotated types must be woven with the AspectJ weaver. You can
|
For this to work, the annotated types must be woven with the AspectJ weaver. You can
|
||||||
either use a build-time Ant or Maven task to do this (see, for example, the
|
either use a build-time Ant or Maven task to do this (see, for example, the
|
||||||
https://www.eclipse.org/aspectj/doc/released/devguide/antTasks.html[AspectJ Development
|
{aspectj-docs-devguide}/antTasks.html[AspectJ Development
|
||||||
Environment Guide]) or load-time weaving (see xref:core/aop/using-aspectj.adoc#aop-aj-ltw[Load-time Weaving with AspectJ in the Spring Framework]). The
|
Environment Guide]) or load-time weaving (see xref:core/aop/using-aspectj.adoc#aop-aj-ltw[Load-time Weaving with AspectJ in the Spring Framework]). The
|
||||||
`AnnotationBeanConfigurerAspect` itself needs to be configured by Spring (in order to obtain
|
`AnnotationBeanConfigurerAspect` itself needs to be configured by Spring (in order to obtain
|
||||||
a reference to the bean factory that is to be used to configure new objects). If you
|
a reference to the bean factory that is to be used to configure new objects). If you
|
||||||
|
|
@ -399,7 +398,7 @@ The focus of this section is on configuring and using LTW in the specific contex
|
||||||
Spring Framework. This section is not a general introduction to LTW. For full details on
|
Spring Framework. This section is not a general introduction to LTW. For full details on
|
||||||
the specifics of LTW and configuring LTW with only AspectJ (with Spring not being
|
the specifics of LTW and configuring LTW with only AspectJ (with Spring not being
|
||||||
involved at all), see the
|
involved at all), see the
|
||||||
https://www.eclipse.org/aspectj/doc/released/devguide/ltw.html[LTW section of the AspectJ
|
{aspectj-docs-devguide}/ltw.html[LTW section of the AspectJ
|
||||||
Development Environment Guide].
|
Development Environment Guide].
|
||||||
|
|
||||||
The value that the Spring Framework brings to AspectJ LTW is in enabling much
|
The value that the Spring Framework brings to AspectJ LTW is in enabling much
|
||||||
|
|
@ -421,7 +420,7 @@ who typically are in charge of the deployment configuration, such as the launch
|
||||||
Now that the sales pitch is over, let us first walk through a quick example of AspectJ
|
Now that the sales pitch is over, let us first walk through a quick example of AspectJ
|
||||||
LTW that uses Spring, followed by detailed specifics about elements introduced in the
|
LTW that uses Spring, followed by detailed specifics about elements introduced in the
|
||||||
example. For a complete example, see the
|
example. For a complete example, see the
|
||||||
https://github.com/spring-projects/spring-petclinic[Petclinic sample application].
|
{spring-github-org}/spring-petclinic[Petclinic sample application].
|
||||||
|
|
||||||
|
|
||||||
[[aop-aj-ltw-first-example]]
|
[[aop-aj-ltw-first-example]]
|
||||||
|
|
@ -621,7 +620,7 @@ java -javaagent:C:/projects/xyz/lib/spring-instrument.jar com.xyz.Main
|
||||||
----
|
----
|
||||||
|
|
||||||
The `-javaagent` is a flag for specifying and enabling
|
The `-javaagent` is a flag for specifying and enabling
|
||||||
https://docs.oracle.com/javase/8/docs/api/java/lang/instrument/package-summary.html[agents
|
{java-api}/java.instrument/java/lang/instrument/package-summary.html[agents
|
||||||
to instrument programs that run on the JVM]. The Spring Framework ships with such an
|
to instrument programs that run on the JVM]. The Spring Framework ships with such an
|
||||||
agent, the `InstrumentationSavingAgent`, which is packaged in the
|
agent, the `InstrumentationSavingAgent`, which is packaged in the
|
||||||
`spring-instrument.jar` that was supplied as the value of the `-javaagent` argument in
|
`spring-instrument.jar` that was supplied as the value of the `-javaagent` argument in
|
||||||
|
|
@ -721,7 +720,7 @@ The AspectJ LTW infrastructure is configured by using one or more `META-INF/aop.
|
||||||
files that are on the Java classpath (either directly or, more typically, in jar files).
|
files that are on the Java classpath (either directly or, more typically, in jar files).
|
||||||
|
|
||||||
The structure and contents of this file is detailed in the LTW part of the
|
The structure and contents of this file is detailed in the LTW part of the
|
||||||
https://www.eclipse.org/aspectj/doc/released/devguide/ltw-configuration.html[AspectJ reference
|
{aspectj-docs-devguide}/ltw-configuration.html[AspectJ reference
|
||||||
documentation]. Because the `aop.xml` file is 100% AspectJ, we do not describe it further here.
|
documentation]. Because the `aop.xml` file is 100% AspectJ, we do not describe it further here.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ Applying such optimizations early implies the following restrictions:
|
||||||
* The beans defined in your application cannot change at runtime, meaning:
|
* The beans defined in your application cannot change at runtime, meaning:
|
||||||
** `@Profile`, in particular profile-specific configuration needs to be chosen at build time.
|
** `@Profile`, in particular profile-specific configuration needs to be chosen at build time.
|
||||||
** `Environment` properties that impact the presence of a bean (`@Conditional`) are only considered at build time.
|
** `Environment` properties that impact the presence of a bean (`@Conditional`) are only considered at build time.
|
||||||
* Bean definitions with instance suppliers (lambdas or method references) cannot be transformed ahead-of-time (see related https://github.com/spring-projects/spring-framework/issues/29555[spring-framework#29555] issue).
|
* Bean definitions with instance suppliers (lambdas or method references) cannot be transformed ahead-of-time (see related {spring-framework-issues}/29555[spring-framework#29555] issue).
|
||||||
* Make sure that the bean type is as precise as possible.
|
* Make sure that the bean type is as precise as possible.
|
||||||
|
|
||||||
TIP: See also the xref:core/aot.adoc#aot.bestpractices[] section.
|
TIP: See also the xref:core/aot.adoc#aot.bestpractices[] section.
|
||||||
|
|
@ -27,7 +27,7 @@ A Spring AOT processed application typically generates:
|
||||||
|
|
||||||
* Java source code
|
* Java source code
|
||||||
* Bytecode (usually for dynamic proxies)
|
* Bytecode (usually for dynamic proxies)
|
||||||
* {api-spring-framework}/aot/hint/RuntimeHints.html[`RuntimeHints`] for the use of reflection, resource loading, serialization, and JDK proxies.
|
* {spring-framework-api}/aot/hint/RuntimeHints.html[`RuntimeHints`] for the use of reflection, resource loading, serialization, and JDK proxies.
|
||||||
|
|
||||||
NOTE: At the moment, AOT is focused on allowing Spring applications to be deployed as native images using GraalVM.
|
NOTE: At the moment, AOT is focused on allowing Spring applications to be deployed as native images using GraalVM.
|
||||||
We intend to support more JVM-based use cases in future generations.
|
We intend to support more JVM-based use cases in future generations.
|
||||||
|
|
@ -35,7 +35,7 @@ We intend to support more JVM-based use cases in future generations.
|
||||||
[[aot.basics]]
|
[[aot.basics]]
|
||||||
== AOT engine overview
|
== AOT engine overview
|
||||||
|
|
||||||
The entry point of the AOT engine for processing an `ApplicationContext` arrangement is `ApplicationContextAotGenerator`. It takes care of the following steps, based on a `GenericApplicationContext` that represents the application to optimize and a {api-spring-framework}/aot/generate/GenerationContext.html[`GenerationContext`]:
|
The entry point of the AOT engine for processing an `ApplicationContext` arrangement is `ApplicationContextAotGenerator`. It takes care of the following steps, based on a `GenericApplicationContext` that represents the application to optimize and a {spring-framework-api}/aot/generate/GenerationContext.html[`GenerationContext`]:
|
||||||
|
|
||||||
* Refresh an `ApplicationContext` for AOT processing. Contrary to a traditional refresh, this version only creates bean definitions, not bean instances.
|
* Refresh an `ApplicationContext` for AOT processing. Contrary to a traditional refresh, this version only creates bean definitions, not bean instances.
|
||||||
* Invoke the available `BeanFactoryInitializationAotProcessor` implementations and apply their contributions against the `GenerationContext`.
|
* Invoke the available `BeanFactoryInitializationAotProcessor` implementations and apply their contributions against the `GenerationContext`.
|
||||||
|
|
@ -81,7 +81,7 @@ Once this part completes, the `BeanFactory` contains the bean definitions that a
|
||||||
[[aot.bean-factory-initialization-contributions]]
|
[[aot.bean-factory-initialization-contributions]]
|
||||||
== Bean Factory Initialization AOT Contributions
|
== Bean Factory Initialization AOT Contributions
|
||||||
|
|
||||||
Components that want to participate in this step can implement the {api-spring-framework}/beans/factory/aot/BeanFactoryInitializationAotProcessor.html[`BeanFactoryInitializationAotProcessor`] interface.
|
Components that want to participate in this step can implement the {spring-framework-api}/beans/factory/aot/BeanFactoryInitializationAotProcessor.html[`BeanFactoryInitializationAotProcessor`] interface.
|
||||||
Each implementation can return an AOT contribution, based on the state of the bean factory.
|
Each implementation can return an AOT contribution, based on the state of the bean factory.
|
||||||
|
|
||||||
An AOT contribution is a component that contributes generated code that reproduces a particular behavior.
|
An AOT contribution is a component that contributes generated code that reproduces a particular behavior.
|
||||||
|
|
@ -261,7 +261,7 @@ If you are registering bean definitions programmatically, consider using `RootBe
|
||||||
The container is able to choose the most appropriate constructor to use based on several candidates.
|
The container is able to choose the most appropriate constructor to use based on several candidates.
|
||||||
However, this is not a best practice and flagging the preferred constructor with `@Autowired` if necessary is preferred.
|
However, this is not a best practice and flagging the preferred constructor with `@Autowired` if necessary is preferred.
|
||||||
|
|
||||||
In case you are working on a code base that you can't modify, you can set the {api-spring-framework}/beans/factory/support/AbstractBeanDefinition.html#PREFERRED_CONSTRUCTORS_ATTRIBUTE[`preferredConstructors` attribute] on the related bean definition to indicate which constructor should be used.
|
In case you are working on a code base that you can't modify, you can set the {spring-framework-api}/beans/factory/support/AbstractBeanDefinition.html#PREFERRED_CONSTRUCTORS_ATTRIBUTE[`preferredConstructors` attribute] on the related bean definition to indicate which constructor should be used.
|
||||||
|
|
||||||
[[aot.bestpractices.factory-bean]]
|
[[aot.bestpractices.factory-bean]]
|
||||||
=== FactoryBean
|
=== FactoryBean
|
||||||
|
|
@ -379,7 +379,7 @@ For instance, GraalVM needs to know ahead of time if a component uses reflection
|
||||||
Similarly, classpath resources are not shipped in a native image unless specified explicitly.
|
Similarly, classpath resources are not shipped in a native image unless specified explicitly.
|
||||||
Consequently, if the application needs to load a resource, it must be referenced from the corresponding GraalVM native image configuration file.
|
Consequently, if the application needs to load a resource, it must be referenced from the corresponding GraalVM native image configuration file.
|
||||||
|
|
||||||
The {api-spring-framework}/aot/hint/RuntimeHints.html[`RuntimeHints`] API collects the need for reflection, resource loading, serialization, and JDK proxies at runtime.
|
The {spring-framework-api}/aot/hint/RuntimeHints.html[`RuntimeHints`] API collects the need for reflection, resource loading, serialization, and JDK proxies at runtime.
|
||||||
The following example makes sure that `config/app.properties` can be loaded from the classpath at runtime within a native image:
|
The following example makes sure that `config/app.properties` can be loaded from the classpath at runtime within a native image:
|
||||||
|
|
||||||
[tabs]
|
[tabs]
|
||||||
|
|
@ -417,7 +417,7 @@ It is also possible to register an implementation statically by adding an entry
|
||||||
[[aot.hints.reflective]]
|
[[aot.hints.reflective]]
|
||||||
=== `@Reflective`
|
=== `@Reflective`
|
||||||
|
|
||||||
{api-spring-framework}/aot/hint/annotation/Reflective.html[`@Reflective`] provides an idiomatic way to flag the need for reflection on an annotated element.
|
{spring-framework-api}/aot/hint/annotation/Reflective.html[`@Reflective`] provides an idiomatic way to flag the need for reflection on an annotated element.
|
||||||
For instance, `@EventListener` is meta-annotated with `@Reflective` since the underlying implementation invokes the annotated method using reflection.
|
For instance, `@EventListener` is meta-annotated with `@Reflective` since the underlying implementation invokes the annotated method using reflection.
|
||||||
|
|
||||||
By default, only Spring beans are considered and an invocation hint is registered for the annotated element.
|
By default, only Spring beans are considered and an invocation hint is registered for the annotated element.
|
||||||
|
|
@ -431,7 +431,7 @@ If components other than Spring beans need to be processed, a `BeanFactoryInitia
|
||||||
[[aot.hints.register-reflection-for-binding]]
|
[[aot.hints.register-reflection-for-binding]]
|
||||||
=== `@RegisterReflectionForBinding`
|
=== `@RegisterReflectionForBinding`
|
||||||
|
|
||||||
{api-spring-framework}/aot/hint/annotation/RegisterReflectionForBinding.html[`@RegisterReflectionForBinding`] is a specialization of `@Reflective` that registers the need for serializing arbitrary types.
|
{spring-framework-api}/aot/hint/annotation/RegisterReflectionForBinding.html[`@RegisterReflectionForBinding`] is a specialization of `@Reflective` that registers the need for serializing arbitrary types.
|
||||||
A typical use case is the use of DTOs that the container cannot infer, such as using a web client within a method body.
|
A typical use case is the use of DTOs that the container cannot infer, such as using a web client within a method body.
|
||||||
|
|
||||||
`@RegisterReflectionForBinding` can be applied to any Spring bean at the class level, but it can also be applied directly to a method, field, or constructor to better indicate where the hints are actually required.
|
`@RegisterReflectionForBinding` can be applied to any Spring bean at the class level, but it can also be applied directly to a method, field, or constructor to better indicate where the hints are actually required.
|
||||||
|
|
@ -467,7 +467,7 @@ include-code::./SpellCheckServiceTests[tag=hintspredicates]
|
||||||
With `RuntimeHintsPredicates`, we can check for reflection, resource, serialization, or proxy generation hints.
|
With `RuntimeHintsPredicates`, we can check for reflection, resource, serialization, or proxy generation hints.
|
||||||
This approach works well for unit tests but implies that the runtime behavior of a component is well known.
|
This approach works well for unit tests but implies that the runtime behavior of a component is well known.
|
||||||
|
|
||||||
You can learn more about the global runtime behavior of an application by running its test suite (or the app itself) with the {docs-graalvm}/native-image/metadata/AutomaticMetadataCollection/[GraalVM tracing agent].
|
You can learn more about the global runtime behavior of an application by running its test suite (or the app itself) with the {graalvm-docs}/native-image/metadata/AutomaticMetadataCollection/[GraalVM tracing agent].
|
||||||
This agent will record all relevant calls requiring GraalVM hints at runtime and write them out as JSON configuration files.
|
This agent will record all relevant calls requiring GraalVM hints at runtime and write them out as JSON configuration files.
|
||||||
|
|
||||||
For more targeted discovery and testing, Spring Framework ships a dedicated module with core AOT testing utilities, `"org.springframework:spring-core-test"`.
|
For more targeted discovery and testing, Spring Framework ships a dedicated module with core AOT testing utilities, `"org.springframework:spring-core-test"`.
|
||||||
|
|
@ -499,4 +499,4 @@ io.spring.runtimehintstesting.SampleReflectionRuntimeHintsTests#lambda$shouldReg
|
||||||
|
|
||||||
There are various ways to configure this Java agent in your build, so please refer to the documentation of your build tool and test execution plugin.
|
There are various ways to configure this Java agent in your build, so please refer to the documentation of your build tool and test execution plugin.
|
||||||
The agent itself can be configured to instrument specific packages (by default, only `org.springframework` is instrumented).
|
The agent itself can be configured to instrument specific packages (by default, only `org.springframework` is instrumented).
|
||||||
You'll find more details in the {spring-framework-main-code}/buildSrc/README.md[Spring Framework `buildSrc` README] file.
|
You'll find more details in the {spring-framework-code}/buildSrc/README.md[Spring Framework `buildSrc` README] file.
|
||||||
|
|
|
||||||
|
|
@ -765,7 +765,7 @@ want to add an additional attribute to the existing bean definition element.
|
||||||
|
|
||||||
By way of another example, suppose that you define a bean definition for a
|
By way of another example, suppose that you define a bean definition for a
|
||||||
service object that (unknown to it) accesses a clustered
|
service object that (unknown to it) accesses a clustered
|
||||||
https://jcp.org/en/jsr/detail?id=107[JCache], and you want to ensure that the
|
{JSR}107[JCache], and you want to ensure that the
|
||||||
named JCache instance is eagerly started within the surrounding cluster.
|
named JCache instance is eagerly started within the surrounding cluster.
|
||||||
The following listing shows such a definition:
|
The following listing shows such a definition:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,13 +66,13 @@ developer's intent ("`inject this constant value`"), and it reads better:
|
||||||
[[xsd-schemas-util-frfb]]
|
[[xsd-schemas-util-frfb]]
|
||||||
==== Setting a Bean Property or Constructor Argument from a Field Value
|
==== Setting a Bean Property or Constructor Argument from a Field Value
|
||||||
|
|
||||||
{api-spring-framework}/beans/factory/config/FieldRetrievingFactoryBean.html[`FieldRetrievingFactoryBean`]
|
{spring-framework-api}/beans/factory/config/FieldRetrievingFactoryBean.html[`FieldRetrievingFactoryBean`]
|
||||||
is a `FactoryBean` that retrieves a `static` or non-static field value. It is typically
|
is a `FactoryBean` that retrieves a `static` or non-static field value. It is typically
|
||||||
used for retrieving `public` `static` `final` constants, which may then be used to set a
|
used for retrieving `public` `static` `final` constants, which may then be used to set a
|
||||||
property value or constructor argument for another bean.
|
property value or constructor argument for another bean.
|
||||||
|
|
||||||
The following example shows how a `static` field is exposed, by using the
|
The following example shows how a `static` field is exposed, by using the
|
||||||
{api-spring-framework}/beans/factory/config/FieldRetrievingFactoryBean.html#setStaticField(java.lang.String)[`staticField`]
|
{spring-framework-api}/beans/factory/config/FieldRetrievingFactoryBean.html#setStaticField(java.lang.String)[`staticField`]
|
||||||
property:
|
property:
|
||||||
|
|
||||||
[source,xml,indent=0,subs="verbatim,quotes"]
|
[source,xml,indent=0,subs="verbatim,quotes"]
|
||||||
|
|
@ -109,7 +109,7 @@ to be specified for the bean reference, as the following example shows:
|
||||||
|
|
||||||
You can also access a non-static (instance) field of another bean, as
|
You can also access a non-static (instance) field of another bean, as
|
||||||
described in the API documentation for the
|
described in the API documentation for the
|
||||||
{api-spring-framework}/beans/factory/config/FieldRetrievingFactoryBean.html[`FieldRetrievingFactoryBean`]
|
{spring-framework-api}/beans/factory/config/FieldRetrievingFactoryBean.html[`FieldRetrievingFactoryBean`]
|
||||||
class.
|
class.
|
||||||
|
|
||||||
Injecting enumeration values into beans as either property or constructor arguments is
|
Injecting enumeration values into beans as either property or constructor arguments is
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ No matter the choice, Spring can accommodate both styles and even mix them toget
|
||||||
It is worth pointing out that through its xref:core/beans/java.adoc[JavaConfig] option, Spring lets
|
It is worth pointing out that through its xref:core/beans/java.adoc[JavaConfig] option, Spring lets
|
||||||
annotations be used in a non-invasive way, without touching the target components'
|
annotations be used in a non-invasive way, without touching the target components'
|
||||||
source code and that, in terms of tooling, all configuration styles are supported by
|
source code and that, in terms of tooling, all configuration styles are supported by
|
||||||
https://spring.io/tools[Spring Tools] for Eclipse, Visual Studio Code, and Theia.
|
{spring-site-tools}[Spring Tools] for Eclipse, Visual Studio Code, and Theia.
|
||||||
****
|
****
|
||||||
|
|
||||||
An alternative to XML setup is provided by annotation-based configuration, which relies
|
An alternative to XML setup is provided by annotation-based configuration, which relies
|
||||||
|
|
@ -62,11 +62,11 @@ configuration (notice the inclusion of the `context` namespace):
|
||||||
|
|
||||||
The `<context:annotation-config/>` element implicitly registers the following post-processors:
|
The `<context:annotation-config/>` element implicitly registers the following post-processors:
|
||||||
|
|
||||||
* {api-spring-framework}/context/annotation/ConfigurationClassPostProcessor.html[`ConfigurationClassPostProcessor`]
|
* {spring-framework-api}/context/annotation/ConfigurationClassPostProcessor.html[`ConfigurationClassPostProcessor`]
|
||||||
* {api-spring-framework}/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.html[`AutowiredAnnotationBeanPostProcessor`]
|
* {spring-framework-api}/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.html[`AutowiredAnnotationBeanPostProcessor`]
|
||||||
* {api-spring-framework}/context/annotation/CommonAnnotationBeanPostProcessor.html[`CommonAnnotationBeanPostProcessor`]
|
* {spring-framework-api}/context/annotation/CommonAnnotationBeanPostProcessor.html[`CommonAnnotationBeanPostProcessor`]
|
||||||
* {api-spring-framework}/orm/jpa/support/PersistenceAnnotationBeanPostProcessor.html[`PersistenceAnnotationBeanPostProcessor`]
|
* {spring-framework-api}/orm/jpa/support/PersistenceAnnotationBeanPostProcessor.html[`PersistenceAnnotationBeanPostProcessor`]
|
||||||
* {api-spring-framework}/context/event/EventListenerMethodProcessor.html[`EventListenerMethodProcessor`]
|
* {spring-framework-api}/context/event/EventListenerMethodProcessor.html[`EventListenerMethodProcessor`]
|
||||||
|
|
||||||
[NOTE]
|
[NOTE]
|
||||||
====
|
====
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
[[beans-custom-autowire-configurer]]
|
[[beans-custom-autowire-configurer]]
|
||||||
= Using `CustomAutowireConfigurer`
|
= Using `CustomAutowireConfigurer`
|
||||||
|
|
||||||
{api-spring-framework}/beans/factory/annotation/CustomAutowireConfigurer.html[`CustomAutowireConfigurer`]
|
{spring-framework-api}/beans/factory/annotation/CustomAutowireConfigurer.html[`CustomAutowireConfigurer`]
|
||||||
is a `BeanFactoryPostProcessor` that lets you register your own custom qualifier
|
is a `BeanFactoryPostProcessor` that lets you register your own custom qualifier
|
||||||
annotation types, even if they are not annotated with Spring's `@Qualifier` annotation.
|
annotation types, even if they are not annotated with Spring's `@Qualifier` annotation.
|
||||||
The following example shows how to use `CustomAutowireConfigurer`:
|
The following example shows how to use `CustomAutowireConfigurer`:
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ Kotlin::
|
||||||
NOTE: The name provided with the annotation is resolved as a bean name by the
|
NOTE: The name provided with the annotation is resolved as a bean name by the
|
||||||
`ApplicationContext` of which the `CommonAnnotationBeanPostProcessor` is aware.
|
`ApplicationContext` of which the `CommonAnnotationBeanPostProcessor` is aware.
|
||||||
The names can be resolved through JNDI if you configure Spring's
|
The names can be resolved through JNDI if you configure Spring's
|
||||||
{api-spring-framework}/jndi/support/SimpleJndiBeanFactory.html[`SimpleJndiBeanFactory`]
|
{spring-framework-api}/jndi/support/SimpleJndiBeanFactory.html[`SimpleJndiBeanFactory`]
|
||||||
explicitly. However, we recommend that you rely on the default behavior and
|
explicitly. However, we recommend that you rely on the default behavior and
|
||||||
use Spring's JNDI lookup capabilities to preserve the level of indirection.
|
use Spring's JNDI lookup capabilities to preserve the level of indirection.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,8 @@ between those objects.
|
||||||
Several implementations of the `ApplicationContext` interface are supplied
|
Several implementations of the `ApplicationContext` interface are supplied
|
||||||
with Spring. In stand-alone applications, it is common to create an
|
with Spring. In stand-alone applications, it is common to create an
|
||||||
instance of
|
instance of
|
||||||
{api-spring-framework}/context/support/ClassPathXmlApplicationContext.html[`ClassPathXmlApplicationContext`]
|
{spring-framework-api}/context/support/ClassPathXmlApplicationContext.html[`ClassPathXmlApplicationContext`]
|
||||||
or {api-spring-framework}/context/support/FileSystemXmlApplicationContext.html[`FileSystemXmlApplicationContext`].
|
or {spring-framework-api}/context/support/FileSystemXmlApplicationContext.html[`FileSystemXmlApplicationContext`].
|
||||||
While XML has been the traditional format for defining configuration metadata, you can
|
While XML has been the traditional format for defining configuration metadata, you can
|
||||||
instruct the container to use Java annotations or code as the metadata format by
|
instruct the container to use Java annotations or code as the metadata format by
|
||||||
providing a small amount of XML configuration to declaratively enable support for these
|
providing a small amount of XML configuration to declaratively enable support for these
|
||||||
|
|
@ -24,7 +24,7 @@ more instances of a Spring IoC container. For example, in a web application scen
|
||||||
simple eight (or so) lines of boilerplate web descriptor XML in the `web.xml` file
|
simple eight (or so) lines of boilerplate web descriptor XML in the `web.xml` file
|
||||||
of the application typically suffices (see
|
of the application typically suffices (see
|
||||||
xref:core/beans/context-introduction.adoc#context-create[Convenient ApplicationContext Instantiation for Web Applications]).
|
xref:core/beans/context-introduction.adoc#context-create[Convenient ApplicationContext Instantiation for Web Applications]).
|
||||||
If you use the https://spring.io/tools[Spring Tools for Eclipse] (an Eclipse-powered
|
If you use the {spring-site-tools}[Spring Tools for Eclipse] (an Eclipse-powered
|
||||||
development environment), you can easily create this boilerplate configuration with a
|
development environment), you can easily create this boilerplate configuration with a
|
||||||
few mouse clicks or keystrokes.
|
few mouse clicks or keystrokes.
|
||||||
|
|
||||||
|
|
@ -61,10 +61,10 @@ For information about using other forms of metadata with the Spring container, s
|
||||||
annotation-based configuration metadata.
|
annotation-based configuration metadata.
|
||||||
* xref:core/beans/java.adoc[Java-based configuration]: define beans external to your application
|
* xref:core/beans/java.adoc[Java-based configuration]: define beans external to your application
|
||||||
classes by using Java rather than XML files. To use these features, see the
|
classes by using Java rather than XML files. To use these features, see the
|
||||||
{api-spring-framework}/context/annotation/Configuration.html[`@Configuration`],
|
{spring-framework-api}/context/annotation/Configuration.html[`@Configuration`],
|
||||||
{api-spring-framework}/context/annotation/Bean.html[`@Bean`],
|
{spring-framework-api}/context/annotation/Bean.html[`@Bean`],
|
||||||
{api-spring-framework}/context/annotation/Import.html[`@Import`],
|
{spring-framework-api}/context/annotation/Import.html[`@Import`],
|
||||||
and {api-spring-framework}/context/annotation/DependsOn.html[`@DependsOn`] annotations.
|
and {spring-framework-api}/context/annotation/DependsOn.html[`@DependsOn`] annotations.
|
||||||
|
|
||||||
Spring configuration consists of at least one and typically more than one bean
|
Spring configuration consists of at least one and typically more than one bean
|
||||||
definition that the container must manage. XML-based configuration metadata configures these
|
definition that the container must manage. XML-based configuration metadata configures these
|
||||||
|
|
|
||||||
|
|
@ -191,7 +191,7 @@ Kotlin::
|
||||||
======
|
======
|
||||||
|
|
||||||
For further details, see the
|
For further details, see the
|
||||||
https://github.com/spring-projects/spring-framework/wiki/Spring-Annotation-Programming-Model[Spring Annotation Programming Model]
|
{spring-framework-wiki}/Spring-Annotation-Programming-Model[Spring Annotation Programming Model]
|
||||||
wiki page.
|
wiki page.
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -315,7 +315,7 @@ entries in the classpath. When you build JARs with Ant, make sure that you do no
|
||||||
activate the files-only switch of the JAR task. Also, classpath directories may not be
|
activate the files-only switch of the JAR task. Also, classpath directories may not be
|
||||||
exposed based on security policies in some environments -- for example, standalone apps on
|
exposed based on security policies in some environments -- for example, standalone apps on
|
||||||
JDK 1.7.0_45 and higher (which requires 'Trusted-Library' setup in your manifests -- see
|
JDK 1.7.0_45 and higher (which requires 'Trusted-Library' setup in your manifests -- see
|
||||||
https://stackoverflow.com/questions/19394570/java-jre-7u45-breaks-classloader-getresources).
|
{stackoverflow-questions}/19394570/java-jre-7u45-breaks-classloader-getresources).
|
||||||
|
|
||||||
On JDK 9's module path (Jigsaw), Spring's classpath scanning generally works as expected.
|
On JDK 9's module path (Jigsaw), Spring's classpath scanning generally works as expected.
|
||||||
However, make sure that your component classes are exported in your `module-info`
|
However, make sure that your component classes are exported in your `module-info`
|
||||||
|
|
@ -743,7 +743,7 @@ Kotlin::
|
||||||
|
|
||||||
If you do not want to rely on the default bean-naming strategy, you can provide a custom
|
If you do not want to rely on the default bean-naming strategy, you can provide a custom
|
||||||
bean-naming strategy. First, implement the
|
bean-naming strategy. First, implement the
|
||||||
{api-spring-framework}/beans/factory/support/BeanNameGenerator.html[`BeanNameGenerator`]
|
{spring-framework-api}/beans/factory/support/BeanNameGenerator.html[`BeanNameGenerator`]
|
||||||
interface, and be sure to include a default no-arg constructor. Then, provide the fully
|
interface, and be sure to include a default no-arg constructor. Then, provide the fully
|
||||||
qualified class name when configuring the scanner, as the following example annotation
|
qualified class name when configuring the scanner, as the following example annotation
|
||||||
and bean definition show.
|
and bean definition show.
|
||||||
|
|
@ -840,7 +840,7 @@ possibly also declaring a custom scoped-proxy mode.
|
||||||
|
|
||||||
NOTE: To provide a custom strategy for scope resolution rather than relying on the
|
NOTE: To provide a custom strategy for scope resolution rather than relying on the
|
||||||
annotation-based approach, you can implement the
|
annotation-based approach, you can implement the
|
||||||
{api-spring-framework}/context/annotation/ScopeMetadataResolver.html[`ScopeMetadataResolver`]
|
{spring-framework-api}/context/annotation/ScopeMetadataResolver.html[`ScopeMetadataResolver`]
|
||||||
interface. Be sure to include a default no-arg constructor. Then you can provide the
|
interface. Be sure to include a default no-arg constructor. Then you can provide the
|
||||||
fully qualified class name when configuring the scanner, as the following example of both
|
fully qualified class name when configuring the scanner, as the following example of both
|
||||||
an annotation and a bean definition shows:
|
an annotation and a bean definition shows:
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
As discussed in the xref:web/webmvc-view/mvc-xslt.adoc#mvc-view-xslt-beandefs[chapter introduction], the `org.springframework.beans.factory`
|
As discussed in the xref:web/webmvc-view/mvc-xslt.adoc#mvc-view-xslt-beandefs[chapter introduction], the `org.springframework.beans.factory`
|
||||||
package provides basic functionality for managing and manipulating beans, including in a
|
package provides basic functionality for managing and manipulating beans, including in a
|
||||||
programmatic way. The `org.springframework.context` package adds the
|
programmatic way. The `org.springframework.context` package adds the
|
||||||
{api-spring-framework}/context/ApplicationContext.html[`ApplicationContext`]
|
{spring-framework-api}/context/ApplicationContext.html[`ApplicationContext`]
|
||||||
interface, which extends the `BeanFactory` interface, in addition to extending other
|
interface, which extends the `BeanFactory` interface, in addition to extending other
|
||||||
interfaces to provide additional functionality in a more application
|
interfaces to provide additional functionality in a more application
|
||||||
framework-oriented style. Many people use the `ApplicationContext` in a completely
|
framework-oriented style. Many people use the `ApplicationContext` in a completely
|
||||||
|
|
@ -269,7 +269,7 @@ file format but is more flexible than the standard JDK based
|
||||||
`ResourceBundleMessageSource` implementation. In particular, it allows for reading
|
`ResourceBundleMessageSource` implementation. In particular, it allows for reading
|
||||||
files from any Spring resource location (not only from the classpath) and supports hot
|
files from any Spring resource location (not only from the classpath) and supports hot
|
||||||
reloading of bundle property files (while efficiently caching them in between).
|
reloading of bundle property files (while efficiently caching them in between).
|
||||||
See the {api-spring-framework}/context/support/ReloadableResourceBundleMessageSource.html[`ReloadableResourceBundleMessageSource`]
|
See the {spring-framework-api}/context/support/ReloadableResourceBundleMessageSource.html[`ReloadableResourceBundleMessageSource`]
|
||||||
javadoc for details.
|
javadoc for details.
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -485,8 +485,8 @@ This means that the `publishEvent()` method blocks until all listeners have fini
|
||||||
One advantage of this synchronous and single-threaded approach is that, when a listener receives an event,
|
One advantage of this synchronous and single-threaded approach is that, when a listener receives an event,
|
||||||
it operates inside the transaction context of the publisher if a transaction context is available.
|
it operates inside the transaction context of the publisher if a transaction context is available.
|
||||||
If another strategy for event publication becomes necessary, e.g. asynchronous event processing by default,
|
If another strategy for event publication becomes necessary, e.g. asynchronous event processing by default,
|
||||||
see the javadoc for Spring's {api-spring-framework}/context/event/ApplicationEventMulticaster.html[`ApplicationEventMulticaster`] interface
|
see the javadoc for Spring's {spring-framework-api}/context/event/ApplicationEventMulticaster.html[`ApplicationEventMulticaster`] interface
|
||||||
and {api-spring-framework}/context/event/SimpleApplicationEventMulticaster.html[`SimpleApplicationEventMulticaster`] implementation
|
and {spring-framework-api}/context/event/SimpleApplicationEventMulticaster.html[`SimpleApplicationEventMulticaster`] implementation
|
||||||
for configuration options which can be applied to a custom "applicationEventMulticaster" bean definition.
|
for configuration options which can be applied to a custom "applicationEventMulticaster" bean definition.
|
||||||
In these cases, ThreadLocals and logging context are not propagated for the event processing.
|
In these cases, ThreadLocals and logging context are not propagated for the event processing.
|
||||||
See xref:integration/observability.adoc#observability.application-events[the `@EventListener` Observability section]
|
See xref:integration/observability.adoc#observability.application-events[the `@EventListener` Observability section]
|
||||||
|
|
@ -529,7 +529,7 @@ notify appropriate parties.
|
||||||
NOTE: Spring's eventing mechanism is designed for simple communication between Spring beans
|
NOTE: Spring's eventing mechanism is designed for simple communication between Spring beans
|
||||||
within the same application context. However, for more sophisticated enterprise
|
within the same application context. However, for more sophisticated enterprise
|
||||||
integration needs, the separately maintained
|
integration needs, the separately maintained
|
||||||
https://projects.spring.io/spring-integration/[Spring Integration] project provides
|
{spring-site-projects}/spring-integration/[Spring Integration] project provides
|
||||||
complete support for building lightweight,
|
complete support for building lightweight,
|
||||||
https://www.enterpriseintegrationpatterns.com[pattern-oriented], event-driven
|
https://www.enterpriseintegrationpatterns.com[pattern-oriented], event-driven
|
||||||
architectures that build upon the well-known Spring programming model.
|
architectures that build upon the well-known Spring programming model.
|
||||||
|
|
@ -742,11 +742,11 @@ Be aware of the following limitations when using asynchronous events:
|
||||||
|
|
||||||
* If an asynchronous event listener throws an `Exception`, it is not propagated to the
|
* If an asynchronous event listener throws an `Exception`, it is not propagated to the
|
||||||
caller. See
|
caller. See
|
||||||
{api-spring-framework}/aop/interceptor/AsyncUncaughtExceptionHandler.html[`AsyncUncaughtExceptionHandler`]
|
{spring-framework-api}/aop/interceptor/AsyncUncaughtExceptionHandler.html[`AsyncUncaughtExceptionHandler`]
|
||||||
for more details.
|
for more details.
|
||||||
* Asynchronous event listener methods cannot publish a subsequent event by returning a
|
* Asynchronous event listener methods cannot publish a subsequent event by returning a
|
||||||
value. If you need to publish another event as the result of the processing, inject an
|
value. If you need to publish another event as the result of the processing, inject an
|
||||||
{api-spring-framework}/context/ApplicationEventPublisher.html[`ApplicationEventPublisher`]
|
{spring-framework-api}/context/ApplicationEventPublisher.html[`ApplicationEventPublisher`]
|
||||||
to publish the event manually.
|
to publish the event manually.
|
||||||
* ThreadLocals and logging context are not propagated by default for the event processing.
|
* ThreadLocals and logging context are not propagated by default for the event processing.
|
||||||
See xref:integration/observability.adoc#observability.application-events[the `@EventListener` Observability section]
|
See xref:integration/observability.adoc#observability.application-events[the `@EventListener` Observability section]
|
||||||
|
|
@ -1040,7 +1040,7 @@ and JMX support facilities. Application components can also interact with the ap
|
||||||
server's JCA `WorkManager` through Spring's `TaskExecutor` abstraction.
|
server's JCA `WorkManager` through Spring's `TaskExecutor` abstraction.
|
||||||
|
|
||||||
See the javadoc of the
|
See the javadoc of the
|
||||||
{api-spring-framework}/jca/context/SpringContextResourceAdapter.html[`SpringContextResourceAdapter`]
|
{spring-framework-api}/jca/context/SpringContextResourceAdapter.html[`SpringContextResourceAdapter`]
|
||||||
class for the configuration details involved in RAR deployment.
|
class for the configuration details involved in RAR deployment.
|
||||||
|
|
||||||
For a simple deployment of a Spring ApplicationContext as a Jakarta EE RAR file:
|
For a simple deployment of a Spring ApplicationContext as a Jakarta EE RAR file:
|
||||||
|
|
@ -1050,7 +1050,7 @@ all application classes into a RAR file (which is a standard JAR file with a dif
|
||||||
file extension).
|
file extension).
|
||||||
. Add all required library JARs into the root of the RAR archive.
|
. Add all required library JARs into the root of the RAR archive.
|
||||||
. Add a
|
. Add a
|
||||||
`META-INF/ra.xml` deployment descriptor (as shown in the {api-spring-framework}/jca/context/SpringContextResourceAdapter.html[javadoc for `SpringContextResourceAdapter`])
|
`META-INF/ra.xml` deployment descriptor (as shown in the {spring-framework-api}/jca/context/SpringContextResourceAdapter.html[javadoc for `SpringContextResourceAdapter`])
|
||||||
and the corresponding Spring XML bean definition file(s) (typically
|
and the corresponding Spring XML bean definition file(s) (typically
|
||||||
`META-INF/applicationContext.xml`).
|
`META-INF/applicationContext.xml`).
|
||||||
. Drop the resulting RAR file into your
|
. Drop the resulting RAR file into your
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ weaver instance. This is particularly useful in combination with
|
||||||
xref:data-access/orm/jpa.adoc[Spring's JPA support] where load-time weaving may be
|
xref:data-access/orm/jpa.adoc[Spring's JPA support] where load-time weaving may be
|
||||||
necessary for JPA class transformation.
|
necessary for JPA class transformation.
|
||||||
Consult the
|
Consult the
|
||||||
{api-spring-framework}/orm/jpa/LocalContainerEntityManagerFactoryBean.html[`LocalContainerEntityManagerFactoryBean`]
|
{spring-framework-api}/orm/jpa/LocalContainerEntityManagerFactoryBean.html[`LocalContainerEntityManagerFactoryBean`]
|
||||||
javadoc for more detail. For more on AspectJ load-time weaving, see xref:core/aop/using-aspectj.adoc#aop-aj-ltw[Load-time Weaving with AspectJ in the Spring Framework].
|
javadoc for more detail. For more on AspectJ load-time weaving, see xref:core/aop/using-aspectj.adoc#aop-aj-ltw[Load-time Weaving with AspectJ in the Spring Framework].
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ container, lets you handle this use case cleanly.
|
||||||
|
|
||||||
****
|
****
|
||||||
You can read more about the motivation for Method Injection in
|
You can read more about the motivation for Method Injection in
|
||||||
https://spring.io/blog/2004/08/06/method-injection/[this blog entry].
|
{spring-site-blog}/2004/08/06/method-injection/[this blog entry].
|
||||||
****
|
****
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ XML configuration:
|
||||||
|
|
||||||
The preceding XML is more succinct. However, typos are discovered at runtime rather than
|
The preceding XML is more succinct. However, typos are discovered at runtime rather than
|
||||||
design time, unless you use an IDE (such as https://www.jetbrains.com/idea/[IntelliJ
|
design time, unless you use an IDE (such as https://www.jetbrains.com/idea/[IntelliJ
|
||||||
IDEA] or the https://spring.io/tools[Spring Tools for Eclipse])
|
IDEA] or the {spring-site-tools}[Spring Tools for Eclipse])
|
||||||
that supports automatic property completion when you create bean definitions. Such IDE
|
that supports automatic property completion when you create bean definitions. Such IDE
|
||||||
assistance is highly recommended.
|
assistance is highly recommended.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
[[beans-environment]]
|
[[beans-environment]]
|
||||||
= Environment Abstraction
|
= Environment Abstraction
|
||||||
|
|
||||||
The {api-spring-framework}/core/env/Environment.html[`Environment`] interface
|
The {spring-framework-api}/core/env/Environment.html[`Environment`] interface
|
||||||
is an abstraction integrated in the container that models two key
|
is an abstraction integrated in the container that models two key
|
||||||
aspects of the application environment: xref:core/beans/environment.adoc#beans-definition-profiles[profiles]
|
aspects of the application environment: xref:core/beans/environment.adoc#beans-definition-profiles[profiles]
|
||||||
and xref:core/beans/environment.adoc#beans-property-source-abstraction[properties].
|
and xref:core/beans/environment.adoc#beans-property-source-abstraction[properties].
|
||||||
|
|
@ -118,7 +118,7 @@ situation B. We start by updating our configuration to reflect this need.
|
||||||
[[beans-definition-profiles-java]]
|
[[beans-definition-profiles-java]]
|
||||||
=== Using `@Profile`
|
=== Using `@Profile`
|
||||||
|
|
||||||
The {api-spring-framework}/context/annotation/Profile.html[`@Profile`]
|
The {spring-framework-api}/context/annotation/Profile.html[`@Profile`]
|
||||||
annotation lets you indicate that a component is eligible for registration
|
annotation lets you indicate that a component is eligible for registration
|
||||||
when one or more specified profiles are active. Using our preceding example, we
|
when one or more specified profiles are active. Using our preceding example, we
|
||||||
can rewrite the `dataSource` configuration as follows:
|
can rewrite the `dataSource` configuration as follows:
|
||||||
|
|
@ -599,17 +599,17 @@ Kotlin::
|
||||||
|
|
||||||
In the preceding snippet, we see a high-level way of asking Spring whether the `my-property` property is
|
In the preceding snippet, we see a high-level way of asking Spring whether the `my-property` property is
|
||||||
defined for the current environment. To answer this question, the `Environment` object performs
|
defined for the current environment. To answer this question, the `Environment` object performs
|
||||||
a search over a set of {api-spring-framework}/core/env/PropertySource.html[`PropertySource`]
|
a search over a set of {spring-framework-api}/core/env/PropertySource.html[`PropertySource`]
|
||||||
objects. A `PropertySource` is a simple abstraction over any source of key-value pairs, and
|
objects. A `PropertySource` is a simple abstraction over any source of key-value pairs, and
|
||||||
Spring's {api-spring-framework}/core/env/StandardEnvironment.html[`StandardEnvironment`]
|
Spring's {spring-framework-api}/core/env/StandardEnvironment.html[`StandardEnvironment`]
|
||||||
is configured with two PropertySource objects -- one representing the set of JVM system properties
|
is configured with two PropertySource objects -- one representing the set of JVM system properties
|
||||||
(`System.getProperties()`) and one representing the set of system environment variables
|
(`System.getProperties()`) and one representing the set of system environment variables
|
||||||
(`System.getenv()`).
|
(`System.getenv()`).
|
||||||
|
|
||||||
NOTE: These default property sources are present for `StandardEnvironment`, for use in standalone
|
NOTE: These default property sources are present for `StandardEnvironment`, for use in standalone
|
||||||
applications. {api-spring-framework}/web/context/support/StandardServletEnvironment.html[`StandardServletEnvironment`]
|
applications. {spring-framework-api}/web/context/support/StandardServletEnvironment.html[`StandardServletEnvironment`]
|
||||||
is populated with additional default property sources including servlet config, servlet
|
is populated with additional default property sources including servlet config, servlet
|
||||||
context parameters, and a {api-spring-framework}/jndi/JndiPropertySource.html[`JndiPropertySource`]
|
context parameters, and a {spring-framework-api}/jndi/JndiPropertySource.html[`JndiPropertySource`]
|
||||||
if JNDI is available.
|
if JNDI is available.
|
||||||
|
|
||||||
Concretely, when you use the `StandardEnvironment`, the call to `env.containsProperty("my-property")`
|
Concretely, when you use the `StandardEnvironment`, the call to `env.containsProperty("my-property")`
|
||||||
|
|
@ -663,7 +663,7 @@ Kotlin::
|
||||||
In the preceding code, `MyPropertySource` has been added with highest precedence in the
|
In the preceding code, `MyPropertySource` has been added with highest precedence in the
|
||||||
search. If it contains a `my-property` property, the property is detected and returned, in favor of
|
search. If it contains a `my-property` property, the property is detected and returned, in favor of
|
||||||
any `my-property` property in any other `PropertySource`. The
|
any `my-property` property in any other `PropertySource`. The
|
||||||
{api-spring-framework}/core/env/MutablePropertySources.html[`MutablePropertySources`]
|
{spring-framework-api}/core/env/MutablePropertySources.html[`MutablePropertySources`]
|
||||||
API exposes a number of methods that allow for precise manipulation of the set of
|
API exposes a number of methods that allow for precise manipulation of the set of
|
||||||
property sources.
|
property sources.
|
||||||
|
|
||||||
|
|
@ -672,7 +672,7 @@ property sources.
|
||||||
[[beans-using-propertysource]]
|
[[beans-using-propertysource]]
|
||||||
== Using `@PropertySource`
|
== Using `@PropertySource`
|
||||||
|
|
||||||
The {api-spring-framework}/context/annotation/PropertySource.html[`@PropertySource`]
|
The {spring-framework-api}/context/annotation/PropertySource.html[`@PropertySource`]
|
||||||
annotation provides a convenient and declarative mechanism for adding a `PropertySource`
|
annotation provides a convenient and declarative mechanism for adding a `PropertySource`
|
||||||
to Spring's `Environment`.
|
to Spring's `Environment`.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@ in which these `BeanPostProcessor` instances run by setting the `order` property
|
||||||
You can set this property only if the `BeanPostProcessor` implements the `Ordered`
|
You can set this property only if the `BeanPostProcessor` implements the `Ordered`
|
||||||
interface. If you write your own `BeanPostProcessor`, you should consider implementing
|
interface. If you write your own `BeanPostProcessor`, you should consider implementing
|
||||||
the `Ordered` interface, too. For further details, see the javadoc of the
|
the `Ordered` interface, too. For further details, see the javadoc of the
|
||||||
{api-spring-framework}/beans/factory/config/BeanPostProcessor.html[`BeanPostProcessor`]
|
{spring-framework-api}/beans/factory/config/BeanPostProcessor.html[`BeanPostProcessor`]
|
||||||
and {api-spring-framework}/core/Ordered.html[`Ordered`] interfaces. See also the note on
|
and {spring-framework-api}/core/Ordered.html[`Ordered`] interfaces. See also the note on
|
||||||
xref:core/beans/factory-extension.adoc#beans-factory-programmatically-registering-beanpostprocessors[programmatic registration of `BeanPostProcessor` instances].
|
xref:core/beans/factory-extension.adoc#beans-factory-programmatically-registering-beanpostprocessors[programmatic registration of `BeanPostProcessor` instances].
|
||||||
|
|
||||||
[NOTE]
|
[NOTE]
|
||||||
|
|
@ -272,8 +272,8 @@ which these `BeanFactoryPostProcessor` instances run by setting the `order` prop
|
||||||
However, you can only set this property if the `BeanFactoryPostProcessor` implements the
|
However, you can only set this property if the `BeanFactoryPostProcessor` implements the
|
||||||
`Ordered` interface. If you write your own `BeanFactoryPostProcessor`, you should
|
`Ordered` interface. If you write your own `BeanFactoryPostProcessor`, you should
|
||||||
consider implementing the `Ordered` interface, too. See the javadoc of the
|
consider implementing the `Ordered` interface, too. See the javadoc of the
|
||||||
{api-spring-framework}/beans/factory/config/BeanFactoryPostProcessor.html[`BeanFactoryPostProcessor`]
|
{spring-framework-api}/beans/factory/config/BeanFactoryPostProcessor.html[`BeanFactoryPostProcessor`]
|
||||||
and {api-spring-framework}/core/Ordered.html[`Ordered`] interfaces for more details.
|
and {spring-framework-api}/core/Ordered.html[`Ordered`] interfaces for more details.
|
||||||
|
|
||||||
[NOTE]
|
[NOTE]
|
||||||
====
|
====
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ The following table describes the supported scopes:
|
||||||
|
|
||||||
NOTE: A thread scope is available but is not registered by default. For more information,
|
NOTE: A thread scope is available but is not registered by default. For more information,
|
||||||
see the documentation for
|
see the documentation for
|
||||||
{api-spring-framework}/context/support/SimpleThreadScope.html[`SimpleThreadScope`].
|
{spring-framework-api}/context/support/SimpleThreadScope.html[`SimpleThreadScope`].
|
||||||
For instructions on how to register this or any other custom scope, see
|
For instructions on how to register this or any other custom scope, see
|
||||||
xref:core/beans/factory-scopes.adoc#beans-factory-scopes-custom-using[Using a Custom Scope].
|
xref:core/beans/factory-scopes.adoc#beans-factory-scopes-custom-using[Using a Custom Scope].
|
||||||
|
|
||||||
|
|
@ -559,7 +559,7 @@ To integrate your custom scopes into the Spring container, you need to implement
|
||||||
`org.springframework.beans.factory.config.Scope` interface, which is described in this
|
`org.springframework.beans.factory.config.Scope` interface, which is described in this
|
||||||
section. For an idea of how to implement your own scopes, see the `Scope`
|
section. For an idea of how to implement your own scopes, see the `Scope`
|
||||||
implementations that are supplied with the Spring Framework itself and the
|
implementations that are supplied with the Spring Framework itself and the
|
||||||
{api-spring-framework}/beans/factory/config/Scope.html[`Scope`] javadoc,
|
{spring-framework-api}/beans/factory/config/Scope.html[`Scope`] javadoc,
|
||||||
which explains the methods you need to implement in more detail.
|
which explains the methods you need to implement in more detail.
|
||||||
|
|
||||||
The `Scope` interface has four methods to get objects from the scope, remove them from
|
The `Scope` interface has four methods to get objects from the scope, remove them from
|
||||||
|
|
@ -629,7 +629,7 @@ Kotlin::
|
||||||
----
|
----
|
||||||
======
|
======
|
||||||
|
|
||||||
See the {api-spring-framework}/beans/factory/config/Scope.html#registerDestructionCallback[javadoc]
|
See the {spring-framework-api}/beans/factory/config/Scope.html#registerDestructionCallback[javadoc]
|
||||||
or a Spring scope implementation for more information on destruction callbacks.
|
or a Spring scope implementation for more information on destruction callbacks.
|
||||||
|
|
||||||
The following method obtains the conversation identifier for the underlying scope:
|
The following method obtains the conversation identifier for the underlying scope:
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,10 @@ construction of classes or a mechanism such as the Service Locator pattern.
|
||||||
|
|
||||||
The `org.springframework.beans` and `org.springframework.context` packages are the basis
|
The `org.springframework.beans` and `org.springframework.context` packages are the basis
|
||||||
for Spring Framework's IoC container. The
|
for Spring Framework's IoC container. The
|
||||||
{api-spring-framework}/beans/factory/BeanFactory.html[`BeanFactory`]
|
{spring-framework-api}/beans/factory/BeanFactory.html[`BeanFactory`]
|
||||||
interface provides an advanced configuration mechanism capable of managing any type of
|
interface provides an advanced configuration mechanism capable of managing any type of
|
||||||
object.
|
object.
|
||||||
{api-spring-framework}/context/ApplicationContext.html[`ApplicationContext`]
|
{spring-framework-api}/context/ApplicationContext.html[`ApplicationContext`]
|
||||||
is a sub-interface of `BeanFactory`. It adds:
|
is a sub-interface of `BeanFactory`. It adds:
|
||||||
|
|
||||||
* Easier integration with Spring's AOP features
|
* Easier integration with Spring's AOP features
|
||||||
|
|
|
||||||
|
|
@ -552,7 +552,7 @@ Sometimes, it is helpful to provide a more detailed textual description of a bea
|
||||||
be particularly useful when beans are exposed (perhaps through JMX) for monitoring purposes.
|
be particularly useful when beans are exposed (perhaps through JMX) for monitoring purposes.
|
||||||
|
|
||||||
To add a description to a `@Bean`, you can use the
|
To add a description to a `@Bean`, you can use the
|
||||||
{api-spring-framework}/context/annotation/Description.html[`@Description`]
|
{spring-framework-api}/context/annotation/Description.html[`@Description`]
|
||||||
annotation, as the following example shows:
|
annotation, as the following example shows:
|
||||||
|
|
||||||
[tabs]
|
[tabs]
|
||||||
|
|
|
||||||
|
|
@ -225,7 +225,7 @@ Also, be particularly careful with `BeanPostProcessor` and `BeanFactoryPostProce
|
||||||
through `@Bean`. Those should usually be declared as `static @Bean` methods, not triggering the
|
through `@Bean`. Those should usually be declared as `static @Bean` methods, not triggering the
|
||||||
instantiation of their containing configuration class. Otherwise, `@Autowired` and `@Value` may not
|
instantiation of their containing configuration class. Otherwise, `@Autowired` and `@Value` may not
|
||||||
work on the configuration class itself, since it is possible to create it as a bean instance earlier than
|
work on the configuration class itself, since it is possible to create it as a bean instance earlier than
|
||||||
{api-spring-framework}/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.html[`AutowiredAnnotationBeanPostProcessor`].
|
{spring-framework-api}/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.html[`AutowiredAnnotationBeanPostProcessor`].
|
||||||
====
|
====
|
||||||
|
|
||||||
The following example shows how one bean can be autowired to another bean:
|
The following example shows how one bean can be autowired to another bean:
|
||||||
|
|
@ -338,7 +338,7 @@ modularity, but determining exactly where the autowired bean definitions are dec
|
||||||
still somewhat ambiguous. For example, as a developer looking at `ServiceConfig`, how do
|
still somewhat ambiguous. For example, as a developer looking at `ServiceConfig`, how do
|
||||||
you know exactly where the `@Autowired AccountRepository` bean is declared? It is not
|
you know exactly where the `@Autowired AccountRepository` bean is declared? It is not
|
||||||
explicit in the code, and this may be just fine. Remember that the
|
explicit in the code, and this may be just fine. Remember that the
|
||||||
https://spring.io/tools[Spring Tools for Eclipse] provides tooling that
|
{spring-site-tools}[Spring Tools for Eclipse] provides tooling that
|
||||||
can render graphs showing how everything is wired, which may be all you need. Also,
|
can render graphs showing how everything is wired, which may be all you need. Also,
|
||||||
your Java IDE can easily find all declarations and uses of the `AccountRepository` type
|
your Java IDE can easily find all declarations and uses of the `AccountRepository` type
|
||||||
and quickly show you the location of `@Bean` methods that return that type.
|
and quickly show you the location of `@Bean` methods that return that type.
|
||||||
|
|
@ -519,7 +519,7 @@ profile has been enabled in the Spring `Environment` (see xref:core/beans/enviro
|
||||||
for details).
|
for details).
|
||||||
|
|
||||||
The `@Profile` annotation is actually implemented by using a much more flexible annotation
|
The `@Profile` annotation is actually implemented by using a much more flexible annotation
|
||||||
called {api-spring-framework}/context/annotation/Conditional.html[`@Conditional`].
|
called {spring-framework-api}/context/annotation/Conditional.html[`@Conditional`].
|
||||||
The `@Conditional` annotation indicates specific
|
The `@Conditional` annotation indicates specific
|
||||||
`org.springframework.context.annotation.Condition` implementations that should be
|
`org.springframework.context.annotation.Condition` implementations that should be
|
||||||
consulted before a `@Bean` is registered.
|
consulted before a `@Bean` is registered.
|
||||||
|
|
@ -570,7 +570,7 @@ Kotlin::
|
||||||
----
|
----
|
||||||
======
|
======
|
||||||
|
|
||||||
See the {api-spring-framework}/context/annotation/Conditional.html[`@Conditional`]
|
See the {spring-framework-api}/context/annotation/Conditional.html[`@Conditional`]
|
||||||
javadoc for more detail.
|
javadoc for more detail.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -278,7 +278,7 @@ init-param):
|
||||||
|
|
||||||
NOTE: For programmatic use cases, a `GenericWebApplicationContext` can be used as an
|
NOTE: For programmatic use cases, a `GenericWebApplicationContext` can be used as an
|
||||||
alternative to `AnnotationConfigWebApplicationContext`. See the
|
alternative to `AnnotationConfigWebApplicationContext`. See the
|
||||||
{api-spring-framework}/web/context/support/GenericWebApplicationContext.html[`GenericWebApplicationContext`]
|
{spring-framework-api}/web/context/support/GenericWebApplicationContext.html[`GenericWebApplicationContext`]
|
||||||
javadoc for details.
|
javadoc for details.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ alternate between read and write.
|
||||||
== `PooledDataBuffer`
|
== `PooledDataBuffer`
|
||||||
|
|
||||||
As explained in the Javadoc for
|
As explained in the Javadoc for
|
||||||
https://docs.oracle.com/javase/8/docs/api/java/nio/ByteBuffer.html[ByteBuffer],
|
{java-api}/java.base/java/nio/ByteBuffer.html[ByteBuffer],
|
||||||
byte buffers can be direct or non-direct. Direct buffers may reside outside the Java heap
|
byte buffers can be direct or non-direct. Direct buffers may reside outside the Java heap
|
||||||
which eliminates the need for copying for native I/O operations. That makes direct buffers
|
which eliminates the need for copying for native I/O operations. That makes direct buffers
|
||||||
particularly useful for receiving and sending data over a socket, but they're also more
|
particularly useful for receiving and sending data over a socket, but they're also more
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ EL, to name a few -- the Spring Expression Language was created to provide the S
|
||||||
community with a single well supported expression language that can be used across all
|
community with a single well supported expression language that can be used across all
|
||||||
the products in the Spring portfolio. Its language features are driven by the
|
the products in the Spring portfolio. Its language features are driven by the
|
||||||
requirements of the projects in the Spring portfolio, including tooling requirements
|
requirements of the projects in the Spring portfolio, including tooling requirements
|
||||||
for code completion support within the https://spring.io/tools[Spring Tools for Eclipse].
|
for code completion support within the {spring-site-tools}[Spring Tools for Eclipse].
|
||||||
That said, SpEL is based on a technology-agnostic API that lets other expression language
|
That said, SpEL is based on a technology-agnostic API that lets other expression language
|
||||||
implementations be integrated, should the need arise.
|
implementations be integrated, should the need arise.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,14 +5,14 @@ Although Java does not let you express null-safety with its type system, the Spr
|
||||||
provides the following annotations in the `org.springframework.lang` package to let you
|
provides the following annotations in the `org.springframework.lang` package to let you
|
||||||
declare nullability of APIs and fields:
|
declare nullability of APIs and fields:
|
||||||
|
|
||||||
* {api-spring-framework}/lang/Nullable.html[`@Nullable`]: Annotation to indicate that a
|
* {spring-framework-api}/lang/Nullable.html[`@Nullable`]: Annotation to indicate that a
|
||||||
specific parameter, return value, or field can be `null`.
|
specific parameter, return value, or field can be `null`.
|
||||||
* {api-spring-framework}/lang/NonNull.html[`@NonNull`]: Annotation to indicate that a specific
|
* {spring-framework-api}/lang/NonNull.html[`@NonNull`]: Annotation to indicate that a specific
|
||||||
parameter, return value, or field cannot be `null` (not needed on parameters, return values,
|
parameter, return value, or field cannot be `null` (not needed on parameters, return values,
|
||||||
and fields where `@NonNullApi` and `@NonNullFields` apply, respectively).
|
and fields where `@NonNullApi` and `@NonNullFields` apply, respectively).
|
||||||
* {api-spring-framework}/lang/NonNullApi.html[`@NonNullApi`]: Annotation at the package level
|
* {spring-framework-api}/lang/NonNullApi.html[`@NonNullApi`]: Annotation at the package level
|
||||||
that declares non-null as the default semantics for parameters and return values.
|
that declares non-null as the default semantics for parameters and return values.
|
||||||
* {api-spring-framework}/lang/NonNullFields.html[`@NonNullFields`]: Annotation at the package
|
* {spring-framework-api}/lang/NonNullFields.html[`@NonNullFields`]: Annotation at the package
|
||||||
level that declares non-null as the default semantics for fields.
|
level that declares non-null as the default semantics for fields.
|
||||||
|
|
||||||
The Spring Framework itself leverages these annotations, but they can also be used in any
|
The Spring Framework itself leverages these annotations, but they can also be used in any
|
||||||
|
|
@ -37,7 +37,7 @@ these annotations can be used by an IDE (such as IDEA or Eclipse) to provide use
|
||||||
warnings related to null-safety in order to avoid `NullPointerException` at runtime.
|
warnings related to null-safety in order to avoid `NullPointerException` at runtime.
|
||||||
|
|
||||||
They are also used to make Spring APIs null-safe in Kotlin projects, since Kotlin natively
|
They are also used to make Spring APIs null-safe in Kotlin projects, since Kotlin natively
|
||||||
supports https://kotlinlang.org/docs/null-safety.html[null-safety]. More details
|
supports {kotlin-docs}/null-safety.html[null-safety]. More details
|
||||||
are available in the xref:languages/kotlin/null-safety.adoc[Kotlin support documentation].
|
are available in the xref:languages/kotlin/null-safety.adoc[Kotlin support documentation].
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -46,7 +46,7 @@ are available in the xref:languages/kotlin/null-safety.adoc[Kotlin support docum
|
||||||
[[jsr-305-meta-annotations]]
|
[[jsr-305-meta-annotations]]
|
||||||
== JSR-305 meta-annotations
|
== JSR-305 meta-annotations
|
||||||
|
|
||||||
Spring annotations are meta-annotated with https://jcp.org/en/jsr/detail?id=305[JSR 305]
|
Spring annotations are meta-annotated with {JSR}305[JSR 305]
|
||||||
annotations (a dormant but widespread JSR). JSR-305 meta-annotations let tooling vendors
|
annotations (a dormant but widespread JSR). JSR-305 meta-annotations let tooling vendors
|
||||||
like IDEA or Kotlin provide null-safety support in a generic way, without having to
|
like IDEA or Kotlin provide null-safety support in a generic way, without having to
|
||||||
hard-code support for Spring annotations.
|
hard-code support for Spring annotations.
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ such as a method to check for the existence of the resource being pointed to.
|
||||||
Spring's `Resource` interface located in the `org.springframework.core.io.` package is
|
Spring's `Resource` interface located in the `org.springframework.core.io.` package is
|
||||||
meant to be a more capable interface for abstracting access to low-level resources. The
|
meant to be a more capable interface for abstracting access to low-level resources. The
|
||||||
following listing provides an overview of the `Resource` interface. See the
|
following listing provides an overview of the `Resource` interface. See the
|
||||||
{api-spring-framework}/core/io/Resource.html[`Resource`] javadoc for further details.
|
{spring-framework-api}/core/io/Resource.html[`Resource`] javadoc for further details.
|
||||||
|
|
||||||
|
|
||||||
[source,java,indent=0,subs="verbatim,quotes"]
|
[source,java,indent=0,subs="verbatim,quotes"]
|
||||||
|
|
@ -104,7 +104,7 @@ resource (if the underlying implementation is compatible and supports that
|
||||||
functionality).
|
functionality).
|
||||||
|
|
||||||
Some implementations of the `Resource` interface also implement the extended
|
Some implementations of the `Resource` interface also implement the extended
|
||||||
{api-spring-framework}/core/io/WritableResource.html[`WritableResource`] interface
|
{spring-framework-api}/core/io/WritableResource.html[`WritableResource`] interface
|
||||||
for a resource that supports writing to it.
|
for a resource that supports writing to it.
|
||||||
|
|
||||||
Spring itself uses the `Resource` abstraction extensively, as an argument type in
|
Spring itself uses the `Resource` abstraction extensively, as an argument type in
|
||||||
|
|
@ -143,7 +143,7 @@ Spring includes several built-in `Resource` implementations:
|
||||||
|
|
||||||
For a complete list of `Resource` implementations available in Spring, consult the
|
For a complete list of `Resource` implementations available in Spring, consult the
|
||||||
"All Known Implementing Classes" section of the
|
"All Known Implementing Classes" section of the
|
||||||
{api-spring-framework}/core/io/Resource.html[`Resource`] javadoc.
|
{spring-framework-api}/core/io/Resource.html[`Resource`] javadoc.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -763,7 +763,7 @@ Kotlin::
|
||||||
----
|
----
|
||||||
======
|
======
|
||||||
|
|
||||||
See the {api-spring-framework}/context/support/ClassPathXmlApplicationContext.html[`ClassPathXmlApplicationContext`]
|
See the {spring-framework-api}/context/support/ClassPathXmlApplicationContext.html[`ClassPathXmlApplicationContext`]
|
||||||
javadoc for details on the various constructors.
|
javadoc for details on the various constructors.
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -903,7 +903,7 @@ entries in the classpath. When you build JARs with Ant, do not activate the `fil
|
||||||
switch of the JAR task. Also, classpath directories may not get exposed based on security
|
switch of the JAR task. Also, classpath directories may not get exposed based on security
|
||||||
policies in some environments -- for example, stand-alone applications on JDK 1.7.0_45
|
policies in some environments -- for example, stand-alone applications on JDK 1.7.0_45
|
||||||
and higher (which requires 'Trusted-Library' to be set up in your manifests. See
|
and higher (which requires 'Trusted-Library' to be set up in your manifests. See
|
||||||
https://stackoverflow.com/questions/19394570/java-jre-7u45-breaks-classloader-getresources).
|
{stackoverflow-questions}/19394570/java-jre-7u45-breaks-classloader-getresources).
|
||||||
|
|
||||||
On JDK 9's module path (Jigsaw), Spring's classpath scanning generally works as expected.
|
On JDK 9's module path (Jigsaw), Spring's classpath scanning generally works as expected.
|
||||||
Putting resources into a dedicated directory is highly recommendable here as well,
|
Putting resources into a dedicated directory is highly recommendable here as well,
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ known as _JUL_ or `java.util.logging`) if neither Log4j 2.x nor SLF4J is availab
|
||||||
|
|
||||||
Put Log4j 2.x or Logback (or another SLF4J provider) in your classpath, without any extra
|
Put Log4j 2.x or Logback (or another SLF4J provider) in your classpath, without any extra
|
||||||
bridges, and let the framework auto-adapt to your choice. For further information see the
|
bridges, and let the framework auto-adapt to your choice. For further information see the
|
||||||
https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-logging[Spring
|
{spring-boot-docs}/features.html#features.logging[Spring
|
||||||
Boot Logging Reference Documentation].
|
Boot Logging Reference Documentation].
|
||||||
|
|
||||||
[NOTE]
|
[NOTE]
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ A JavaBean is a class with a default no-argument constructor and that follows
|
||||||
a naming convention where (for example) a property named `bingoMadness` would
|
a naming convention where (for example) a property named `bingoMadness` would
|
||||||
have a setter method `setBingoMadness(..)` and a getter method `getBingoMadness()`. For
|
have a setter method `setBingoMadness(..)` and a getter method `getBingoMadness()`. For
|
||||||
more information about JavaBeans and the specification, see
|
more information about JavaBeans and the specification, see
|
||||||
https://docs.oracle.com/javase/8/docs/api/java/beans/package-summary.html[javabeans].
|
{java-api}/java.desktop/java/beans/package-summary.html[javabeans].
|
||||||
|
|
||||||
One quite important class in the beans package is the `BeanWrapper` interface and its
|
One quite important class in the beans package is the `BeanWrapper` interface and its
|
||||||
corresponding implementation (`BeanWrapperImpl`). As quoted from the javadoc, the
|
corresponding implementation (`BeanWrapperImpl`). As quoted from the javadoc, the
|
||||||
|
|
@ -249,7 +249,7 @@ behavior can be achieved by registering custom editors of type
|
||||||
`java.beans.PropertyEditor`. Registering custom editors on a `BeanWrapper` or,
|
`java.beans.PropertyEditor`. Registering custom editors on a `BeanWrapper` or,
|
||||||
alternatively, in a specific IoC container (as mentioned in the previous chapter), gives it
|
alternatively, in a specific IoC container (as mentioned in the previous chapter), gives it
|
||||||
the knowledge of how to convert properties to the desired type. For more about
|
the knowledge of how to convert properties to the desired type. For more about
|
||||||
`PropertyEditor`, see https://docs.oracle.com/javase/8/docs/api/java/beans/package-summary.html[the javadoc of the `java.beans` package from Oracle].
|
`PropertyEditor`, see {java-api}/java.desktop/java/beans/package-summary.html[the javadoc of the `java.beans` package from Oracle].
|
||||||
|
|
||||||
A couple of examples where property editing is used in Spring:
|
A couple of examples where property editing is used in Spring:
|
||||||
|
|
||||||
|
|
@ -355,7 +355,7 @@ com
|
||||||
|
|
||||||
Note that you can also use the standard `BeanInfo` JavaBeans mechanism here as well
|
Note that you can also use the standard `BeanInfo` JavaBeans mechanism here as well
|
||||||
(described to some extent
|
(described to some extent
|
||||||
https://docs.oracle.com/javase/tutorial/javabeans/advanced/customization.html[here]). The
|
{java-tutorial}/javabeans/advanced/customization.html[here]). The
|
||||||
following example uses the `BeanInfo` mechanism to explicitly register one or more
|
following example uses the `BeanInfo` mechanism to explicitly register one or more
|
||||||
`PropertyEditor` instances with the properties of an associated class:
|
`PropertyEditor` instances with the properties of an associated class:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
= Java Bean Validation
|
= Java Bean Validation
|
||||||
|
|
||||||
The Spring Framework provides support for the
|
The Spring Framework provides support for the
|
||||||
https://beanvalidation.org/[Java Bean Validation] API.
|
{bean-validation-site}[Java Bean Validation] API.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -72,7 +72,7 @@ Kotlin::
|
||||||
======
|
======
|
||||||
|
|
||||||
A Bean Validation validator then validates instances of this class based on the declared
|
A Bean Validation validator then validates instances of this class based on the declared
|
||||||
constraints. See https://beanvalidation.org/[Bean Validation] for general information about
|
constraints. See {bean-validation-site}[Bean Validation] for general information about
|
||||||
the API. See the https://hibernate.org/validator/[Hibernate Validator] documentation for
|
the API. See the https://hibernate.org/validator/[Hibernate Validator] documentation for
|
||||||
specific constraints. To learn how to set up a bean validation provider as a Spring
|
specific constraints. To learn how to set up a bean validation provider as a Spring
|
||||||
bean, keep reading.
|
bean, keep reading.
|
||||||
|
|
@ -317,7 +317,7 @@ XML::
|
||||||
To be eligible for Spring-driven method validation, target classes need to be annotated
|
To be eligible for Spring-driven method validation, target classes need to be annotated
|
||||||
with Spring's `@Validated` annotation, which can optionally also declare the validation
|
with Spring's `@Validated` annotation, which can optionally also declare the validation
|
||||||
groups to use. See
|
groups to use. See
|
||||||
{api-spring-framework}/validation/beanvalidation/MethodValidationPostProcessor.html[`MethodValidationPostProcessor`]
|
{spring-framework-api}/validation/beanvalidation/MethodValidationPostProcessor.html[`MethodValidationPostProcessor`]
|
||||||
for setup details with the Hibernate Validator and Bean Validation providers.
|
for setup details with the Hibernate Validator and Bean Validation providers.
|
||||||
|
|
||||||
[TIP]
|
[TIP]
|
||||||
|
|
@ -472,7 +472,7 @@ Max.degrees=You cannot provide more than {1} {0}
|
||||||
The default `LocalValidatorFactoryBean` configuration suffices for most
|
The default `LocalValidatorFactoryBean` configuration suffices for most
|
||||||
cases. There are a number of configuration options for various Bean Validation
|
cases. There are a number of configuration options for various Bean Validation
|
||||||
constructs, from message interpolation to traversal resolution. See the
|
constructs, from message interpolation to traversal resolution. See the
|
||||||
{api-spring-framework}/validation/beanvalidation/LocalValidatorFactoryBean.html[`LocalValidatorFactoryBean`]
|
{spring-framework-api}/validation/beanvalidation/LocalValidatorFactoryBean.html[`LocalValidatorFactoryBean`]
|
||||||
javadoc for more information on these options.
|
javadoc for more information on these options.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@ of the field). This is done as a convenience to aid developers when targeting er
|
||||||
|
|
||||||
More information on the `MessageCodesResolver` and the default strategy can be found
|
More information on the `MessageCodesResolver` and the default strategy can be found
|
||||||
in the javadoc of
|
in the javadoc of
|
||||||
{api-spring-framework}/validation/MessageCodesResolver.html[`MessageCodesResolver`] and
|
{spring-framework-api}/validation/MessageCodesResolver.html[`MessageCodesResolver`] and
|
||||||
{api-spring-framework}/validation/DefaultMessageCodesResolver.html[`DefaultMessageCodesResolver`],
|
{spring-framework-api}/validation/DefaultMessageCodesResolver.html[`DefaultMessageCodesResolver`],
|
||||||
respectively.
|
respectively.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ Kotlin::
|
||||||
======
|
======
|
||||||
|
|
||||||
The Spring team welcomes community-driven `Formatter` contributions. See
|
The Spring team welcomes community-driven `Formatter` contributions. See
|
||||||
https://github.com/spring-projects/spring-framework/issues[GitHub Issues] to contribute.
|
{spring-framework-issues}[GitHub Issues] to contribute.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ Kotlin::
|
||||||
|
|
||||||
The `static` `rejectIfEmpty(..)` method on the `ValidationUtils` class is used to
|
The `static` `rejectIfEmpty(..)` method on the `ValidationUtils` class is used to
|
||||||
reject the `name` property if it is `null` or the empty string. Have a look at the
|
reject the `name` property if it is `null` or the empty string. Have a look at the
|
||||||
{api-spring-framework}/validation/ValidationUtils.html[`ValidationUtils`] javadoc
|
{spring-framework-api}/validation/ValidationUtils.html[`ValidationUtils`] javadoc
|
||||||
to see what functionality it provides besides the example shown previously.
|
to see what functionality it provides besides the example shown previously.
|
||||||
|
|
||||||
While it is certainly possible to implement a single `Validator` class to validate each
|
While it is certainly possible to implement a single `Validator` class to validate each
|
||||||
|
|
@ -193,7 +193,7 @@ Kotlin::
|
||||||
Validation errors are reported to the `Errors` object passed to the validator. In the case
|
Validation errors are reported to the `Errors` object passed to the validator. In the case
|
||||||
of Spring Web MVC, you can use the `<spring:bind/>` tag to inspect the error messages, but
|
of Spring Web MVC, you can use the `<spring:bind/>` tag to inspect the error messages, but
|
||||||
you can also inspect the `Errors` object yourself. More information about the
|
you can also inspect the `Errors` object yourself. More information about the
|
||||||
methods it offers can be found in the {api-spring-framework}/validation/Errors.html[javadoc].
|
methods it offers can be found in the {spring-framework-api}/validation/Errors.html[javadoc].
|
||||||
|
|
||||||
Validators may also get locally invoked for the immediate validation of a given object,
|
Validators may also get locally invoked for the immediate validation of a given object,
|
||||||
not involving a binding process. As of 6.1, this has been simplified through a new
|
not involving a binding process. As of 6.1, this has been simplified through a new
|
||||||
|
|
|
||||||
|
|
@ -199,7 +199,7 @@ participating in Spring managed transactions. It is generally preferable to writ
|
||||||
own new code by using the higher level abstractions for resource management, such as
|
own new code by using the higher level abstractions for resource management, such as
|
||||||
`JdbcTemplate` or `DataSourceUtils`.
|
`JdbcTemplate` or `DataSourceUtils`.
|
||||||
|
|
||||||
See the {api-spring-framework}/jdbc/datasource/TransactionAwareDataSourceProxy.html[`TransactionAwareDataSourceProxy`]
|
See the {spring-framework-api}/jdbc/datasource/TransactionAwareDataSourceProxy.html[`TransactionAwareDataSourceProxy`]
|
||||||
javadoc for more details.
|
javadoc for more details.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ corresponding to the fully qualified class name of the template instance (typica
|
||||||
|
|
||||||
The following sections provide some examples of `JdbcTemplate` usage. These examples
|
The following sections provide some examples of `JdbcTemplate` usage. These examples
|
||||||
are not an exhaustive list of all of the functionality exposed by the `JdbcTemplate`.
|
are not an exhaustive list of all of the functionality exposed by the `JdbcTemplate`.
|
||||||
See the attendant {api-spring-framework}/jdbc/core/JdbcTemplate.html[javadoc] for that.
|
See the attendant {spring-framework-api}/jdbc/core/JdbcTemplate.html[javadoc] for that.
|
||||||
|
|
||||||
[[jdbc-JdbcTemplate-examples-query]]
|
[[jdbc-JdbcTemplate-examples-query]]
|
||||||
=== Querying (`SELECT`)
|
=== Querying (`SELECT`)
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ Kotlin::
|
||||||
----
|
----
|
||||||
======
|
======
|
||||||
|
|
||||||
See the {api-spring-framework}/jdbc/datasource/embedded/EmbeddedDatabaseBuilder.html[javadoc for `EmbeddedDatabaseBuilder`]
|
See the {spring-framework-api}/jdbc/datasource/embedded/EmbeddedDatabaseBuilder.html[javadoc for `EmbeddedDatabaseBuilder`]
|
||||||
for further details on all supported options.
|
for further details on all supported options.
|
||||||
|
|
||||||
You can also use the `EmbeddedDatabaseBuilder` to create an embedded database by using Java
|
You can also use the `EmbeddedDatabaseBuilder` to create an embedded database by using Java
|
||||||
|
|
@ -288,7 +288,7 @@ You can extend Spring JDBC embedded database support in two ways:
|
||||||
connection pool to manage embedded database connections.
|
connection pool to manage embedded database connections.
|
||||||
|
|
||||||
We encourage you to contribute extensions to the Spring community at
|
We encourage you to contribute extensions to the Spring community at
|
||||||
https://github.com/spring-projects/spring-framework/issues[GitHub Issues].
|
{spring-framework-issues}[GitHub Issues].
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,8 +58,8 @@ The benefits of using the Spring Framework to create your ORM DAOs include:
|
||||||
|
|
||||||
TIP: For more comprehensive ORM support, including support for alternative database
|
TIP: For more comprehensive ORM support, including support for alternative database
|
||||||
technologies such as MongoDB, you might want to check out the
|
technologies such as MongoDB, you might want to check out the
|
||||||
https://projects.spring.io/spring-data/[Spring Data] suite of projects. If you are
|
{spring-site-projects}/spring-data/[Spring Data] suite of projects. If you are
|
||||||
a JPA user, the https://spring.io/guides/gs/accessing-data-jpa/[Getting Started Accessing
|
a JPA user, the {spring-site-guides}/gs/accessing-data-jpa/[Getting Started Accessing
|
||||||
Data with JPA] guide from https://spring.io provides a great introduction.
|
Data with JPA] guide from https://spring.io provides a great introduction.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -157,7 +157,7 @@ The `LoadTimeWeaver` interface is a Spring-provided class that lets JPA
|
||||||
`ClassTransformer` instances be plugged in a specific manner, depending on whether the
|
`ClassTransformer` instances be plugged in a specific manner, depending on whether the
|
||||||
environment is a web container or application server. Hooking `ClassTransformers`
|
environment is a web container or application server. Hooking `ClassTransformers`
|
||||||
through an
|
through an
|
||||||
https://docs.oracle.com/javase/6/docs/api/java/lang/instrument/package-summary.html[agent]
|
{java-api}/java.instrument/java/lang/instrument/package-summary.html[agent]
|
||||||
is typically not efficient. The agents work against the entire virtual machine and
|
is typically not efficient. The agents work against the entire virtual machine and
|
||||||
inspect every class that is loaded, which is usually undesirable in a production
|
inspect every class that is loaded, which is usually undesirable in a production
|
||||||
server environment.
|
server environment.
|
||||||
|
|
@ -541,8 +541,8 @@ way of auto-configuring an `EntityManagerFactory` setup for Hibernate or Eclipse
|
||||||
respectively. Note that those provider adapters are primarily designed for use with
|
respectively. Note that those provider adapters are primarily designed for use with
|
||||||
Spring-driven transaction management (that is, for use with `JpaTransactionManager`).
|
Spring-driven transaction management (that is, for use with `JpaTransactionManager`).
|
||||||
|
|
||||||
See the {api-spring-framework}/orm/jpa/JpaDialect.html[`JpaDialect`] and
|
See the {spring-framework-api}/orm/jpa/JpaDialect.html[`JpaDialect`] and
|
||||||
{api-spring-framework}/orm/jpa/JpaVendorAdapter.html[`JpaVendorAdapter`] javadoc for
|
{spring-framework-api}/orm/jpa/JpaVendorAdapter.html[`JpaVendorAdapter`] javadoc for
|
||||||
more details of its operations and how they are used within Spring's JPA support.
|
more details of its operations and how they are used within Spring's JPA support.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,8 @@ simpler.
|
||||||
[[oxm-consistent-interfaces]]
|
[[oxm-consistent-interfaces]]
|
||||||
=== Consistent Interfaces
|
=== Consistent Interfaces
|
||||||
|
|
||||||
Spring's O-X mapping operates through two global interfaces: {api-spring-framework}/oxm/Marshaller.html[`Marshaller`] and
|
Spring's O-X mapping operates through two global interfaces: {spring-framework-api}/oxm/Marshaller.html[`Marshaller`] and
|
||||||
{api-spring-framework}/oxm/Unmarshaller.html[`Unmarshaller`]. These abstractions let you switch O-X mapping frameworks
|
{spring-framework-api}/oxm/Unmarshaller.html[`Unmarshaller`]. These abstractions let you switch O-X mapping frameworks
|
||||||
with relative ease, with little or no change required on the classes that do the
|
with relative ease, with little or no change required on the classes that do the
|
||||||
marshalling. This approach has the additional benefit of making it possible to do XML
|
marshalling. This approach has the additional benefit of making it possible to do XML
|
||||||
marshalling with a mix-and-match approach (for example, some marshalling performed using JAXB
|
marshalling with a mix-and-match approach (for example, some marshalling performed using JAXB
|
||||||
|
|
@ -557,7 +557,7 @@ set the `supportedClasses` property on the `XStreamMarshaller`, as the following
|
||||||
Doing so ensures that only the registered classes are eligible for unmarshalling.
|
Doing so ensures that only the registered classes are eligible for unmarshalling.
|
||||||
|
|
||||||
Additionally, you can register
|
Additionally, you can register
|
||||||
{api-spring-framework}/oxm/xstream/XStreamMarshaller.html#setConverters(com.thoughtworks.xstream.converters.ConverterMatcher...)[custom
|
{spring-framework-api}/oxm/xstream/XStreamMarshaller.html#setConverters(com.thoughtworks.xstream.converters.ConverterMatcher...)[custom
|
||||||
converters] to make sure that only your supported classes can be unmarshalled. You might
|
converters] to make sure that only your supported classes can be unmarshalled. You might
|
||||||
want to add a `CatchAllConverter` as the last converter in the list, in addition to
|
want to add a `CatchAllConverter` as the last converter in the list, in addition to
|
||||||
converters that explicitly support the domain classes that should be supported. As a
|
converters that explicitly support the domain classes that should be supported. As a
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ parameter to database bind marker translation.
|
||||||
run.
|
run.
|
||||||
* `….namedParameters(false)`: Disable named parameter expansion. Enabled by default.
|
* `….namedParameters(false)`: Disable named parameter expansion. Enabled by default.
|
||||||
|
|
||||||
TIP: Dialects are resolved by {api-spring-framework}/r2dbc/core/binding/BindMarkersFactoryResolver.html[`BindMarkersFactoryResolver`]
|
TIP: Dialects are resolved by {spring-framework-api}/r2dbc/core/binding/BindMarkersFactoryResolver.html[`BindMarkersFactoryResolver`]
|
||||||
from a `ConnectionFactory`, typically by inspecting `ConnectionFactoryMetadata`.
|
from a `ConnectionFactory`, typically by inspecting `ConnectionFactoryMetadata`.
|
||||||
+
|
+
|
||||||
You can let Spring auto-discover your `BindMarkersFactory` by registering a
|
You can let Spring auto-discover your `BindMarkersFactory` by registering a
|
||||||
|
|
@ -120,7 +120,7 @@ the reactive sequence to aid debugging.
|
||||||
|
|
||||||
The following sections provide some examples of `DatabaseClient` usage. These examples
|
The following sections provide some examples of `DatabaseClient` usage. These examples
|
||||||
are not an exhaustive list of all of the functionality exposed by the `DatabaseClient`.
|
are not an exhaustive list of all of the functionality exposed by the `DatabaseClient`.
|
||||||
See the attendant {api-spring-framework}/r2dbc/core/DatabaseClient.html[javadoc] for that.
|
See the attendant {spring-framework-api}/r2dbc/core/DatabaseClient.html[javadoc] for that.
|
||||||
|
|
||||||
[[r2dbc-DatabaseClient-examples-statement]]
|
[[r2dbc-DatabaseClient-examples-statement]]
|
||||||
==== Executing Statements
|
==== Executing Statements
|
||||||
|
|
@ -752,7 +752,7 @@ the same time, have this client participating in Spring managed transactions. It
|
||||||
preferable to integrate a R2DBC client with proper access to `ConnectionFactoryUtils`
|
preferable to integrate a R2DBC client with proper access to `ConnectionFactoryUtils`
|
||||||
for resource management.
|
for resource management.
|
||||||
|
|
||||||
See the {api-spring-framework}/r2dbc/connection/TransactionAwareConnectionFactoryProxy.html[`TransactionAwareConnectionFactoryProxy`]
|
See the {spring-framework-api}/r2dbc/connection/TransactionAwareConnectionFactoryProxy.html[`TransactionAwareConnectionFactoryProxy`]
|
||||||
javadoc for more details.
|
javadoc for more details.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ the JTA `UserTransaction` and `TransactionManager` objects) autodetects the loca
|
||||||
the latter object, which varies by application server. Having access to the JTA
|
the latter object, which varies by application server. Having access to the JTA
|
||||||
`TransactionManager` allows for enhanced transaction semantics -- in particular,
|
`TransactionManager` allows for enhanced transaction semantics -- in particular,
|
||||||
supporting transaction suspension. See the
|
supporting transaction suspension. See the
|
||||||
{api-spring-framework}/transaction/jta/JtaTransactionManager.html[`JtaTransactionManager`]
|
{spring-framework-api}/transaction/jta/JtaTransactionManager.html[`JtaTransactionManager`]
|
||||||
javadoc for details.
|
javadoc for details.
|
||||||
|
|
||||||
Spring's `JtaTransactionManager` is the standard choice to run on Jakarta EE application
|
Spring's `JtaTransactionManager` is the standard choice to run on Jakarta EE application
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ subclass-level annotation.
|
||||||
When a POJO class such as the one above is defined as a bean in a Spring context,
|
When a POJO class such as the one above is defined as a bean in a Spring context,
|
||||||
you can make the bean instance transactional through an `@EnableTransactionManagement`
|
you can make the bean instance transactional through an `@EnableTransactionManagement`
|
||||||
annotation in a `@Configuration` class. See the
|
annotation in a `@Configuration` class. See the
|
||||||
{api-spring-framework}/transaction/annotation/EnableTransactionManagement.html[javadoc]
|
{spring-framework-api}/transaction/annotation/EnableTransactionManagement.html[javadoc]
|
||||||
for full details.
|
for full details.
|
||||||
|
|
||||||
In XML configuration, the `<tx:annotation-driven/>` tag provides similar convenience:
|
In XML configuration, the `<tx:annotation-driven/>` tag provides similar convenience:
|
||||||
|
|
@ -262,7 +262,7 @@ is modified) to support `@Transactional` runtime behavior on any kind of method.
|
||||||
| XML Attribute| Annotation Attribute| Default| Description
|
| XML Attribute| Annotation Attribute| Default| Description
|
||||||
|
|
||||||
| `transaction-manager`
|
| `transaction-manager`
|
||||||
| N/A (see {api-spring-framework}/transaction/annotation/TransactionManagementConfigurer.html[`TransactionManagementConfigurer`] javadoc)
|
| N/A (see {spring-framework-api}/transaction/annotation/TransactionManagementConfigurer.html[`TransactionManagementConfigurer`] javadoc)
|
||||||
| `transactionManager`
|
| `transactionManager`
|
||||||
| Name of the transaction manager to use. Required only if the name of the transaction
|
| Name of the transaction manager to use. Required only if the name of the transaction
|
||||||
manager is not `transactionManager`, as in the preceding example.
|
manager is not `transactionManager`, as in the preceding example.
|
||||||
|
|
|
||||||
|
|
@ -57,8 +57,7 @@ transaction semantics given by the class annotation (if present). You can annota
|
||||||
regardless of visibility.
|
regardless of visibility.
|
||||||
|
|
||||||
To weave your applications with the `AnnotationTransactionAspect`, you must either build
|
To weave your applications with the `AnnotationTransactionAspect`, you must either build
|
||||||
your application with AspectJ (see the
|
your application with AspectJ (see the {aspectj-docs-devguide}/index.html[AspectJ Development
|
||||||
https://www.eclipse.org/aspectj/doc/released/devguide/index.html[AspectJ Development
|
|
||||||
Guide]) or use load-time weaving. See xref:core/aop/using-aspectj.adoc#aop-aj-ltw[Load-time weaving with AspectJ in the Spring Framework]
|
Guide]) or use load-time weaving. See xref:core/aop/using-aspectj.adoc#aop-aj-ltw[Load-time weaving with AspectJ in the Spring Framework]
|
||||||
for a discussion of load-time weaving with AspectJ.
|
for a discussion of load-time weaving with AspectJ.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,6 @@ that it can roll back to. Such partial rollbacks let an inner transaction scope
|
||||||
trigger a rollback for its scope, with the outer transaction being able to continue
|
trigger a rollback for its scope, with the outer transaction being able to continue
|
||||||
the physical transaction despite some operations having been rolled back. This setting
|
the physical transaction despite some operations having been rolled back. This setting
|
||||||
is typically mapped onto JDBC savepoints, so it works only with JDBC resource
|
is typically mapped onto JDBC savepoints, so it works only with JDBC resource
|
||||||
transactions. See Spring's {api-spring-framework}/jdbc/datasource/DataSourceTransactionManager.html[`DataSourceTransactionManager`].
|
transactions. See Spring's {spring-framework-api}/jdbc/datasource/DataSourceTransactionManager.html[`DataSourceTransactionManager`].
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ For the former, listeners are guaranteed to see the current thread-bound transac
|
||||||
Since the latter uses the Reactor context instead of thread-local variables, the transaction
|
Since the latter uses the Reactor context instead of thread-local variables, the transaction
|
||||||
context needs to be included in the published event instance as the event source.
|
context needs to be included in the published event instance as the event source.
|
||||||
See the
|
See the
|
||||||
{api-spring-framework}/transaction/reactive/TransactionalEventPublisher.html[`TransactionalEventPublisher`]
|
{spring-framework-api}/transaction/reactive/TransactionalEventPublisher.html[`TransactionalEventPublisher`]
|
||||||
javadoc for details.
|
javadoc for details.
|
||||||
====
|
====
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ xref:integration.adoc[Integration] :: REST Clients, JMS, JCA, JMX,
|
||||||
Email, Tasks, Scheduling, Caching, Observability, JVM Checkpoint Restore.
|
Email, Tasks, Scheduling, Caching, Observability, JVM Checkpoint Restore.
|
||||||
xref:languages.adoc[Languages] :: Kotlin, Groovy, Dynamic Languages.
|
xref:languages.adoc[Languages] :: Kotlin, Groovy, Dynamic Languages.
|
||||||
xref:testing/appendix.adoc[Appendix] :: Spring properties.
|
xref:testing/appendix.adoc[Appendix] :: Spring properties.
|
||||||
https://github.com/spring-projects/spring-framework/wiki[Wiki] :: What's New,
|
{spring-framework-wiki}[Wiki] :: What's New,
|
||||||
Upgrade Notes, Supported Versions, additional cross-version information.
|
Upgrade Notes, Supported Versions, additional cross-version information.
|
||||||
|
|
||||||
Rod Johnson, Juergen Hoeller, Keith Donald, Colin Sampaleanu, Rob Harrop, Thomas Risberg,
|
Rod Johnson, Juergen Hoeller, Keith Donald, Colin Sampaleanu, Rob Harrop, Thomas Risberg,
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ To provide a different default key generator, you need to implement the
|
||||||
The default key generation strategy changed with the release of Spring 4.0. Earlier
|
The default key generation strategy changed with the release of Spring 4.0. Earlier
|
||||||
versions of Spring used a key generation strategy that, for multiple key parameters,
|
versions of Spring used a key generation strategy that, for multiple key parameters,
|
||||||
considered only the `hashCode()` of parameters and not `equals()`. This could cause
|
considered only the `hashCode()` of parameters and not `equals()`. This could cause
|
||||||
unexpected key collisions (see https://jira.spring.io/browse/SPR-10237[SPR-10237]
|
unexpected key collisions (see {spring-framework-issues}/14870[spring-framework#14870]
|
||||||
for background). The new `SimpleKeyGenerator` uses a compound key for such scenarios.
|
for background). The new `SimpleKeyGenerator` uses a compound key for such scenarios.
|
||||||
|
|
||||||
If you want to keep using the previous key strategy, you can configure the deprecated
|
If you want to keep using the previous key strategy, you can configure the deprecated
|
||||||
|
|
@ -566,7 +566,7 @@ switching to `aspectj` mode in combination with compile-time or load-time weavin
|
||||||
|
|
||||||
NOTE: For more detail about advanced customizations (using Java configuration) that are
|
NOTE: For more detail about advanced customizations (using Java configuration) that are
|
||||||
required to implement `CachingConfigurer`, see the
|
required to implement `CachingConfigurer`, see the
|
||||||
{api-spring-framework}/cache/annotation/CachingConfigurer.html[javadoc].
|
{spring-framework-api}/cache/annotation/CachingConfigurer.html[javadoc].
|
||||||
|
|
||||||
[[cache-annotation-driven-settings]]
|
[[cache-annotation-driven-settings]]
|
||||||
.Cache annotation settings
|
.Cache annotation settings
|
||||||
|
|
@ -575,7 +575,7 @@ required to implement `CachingConfigurer`, see the
|
||||||
| XML Attribute | Annotation Attribute | Default | Description
|
| XML Attribute | Annotation Attribute | Default | Description
|
||||||
|
|
||||||
| `cache-manager`
|
| `cache-manager`
|
||||||
| N/A (see the {api-spring-framework}/cache/annotation/CachingConfigurer.html[`CachingConfigurer`] javadoc)
|
| N/A (see the {spring-framework-api}/cache/annotation/CachingConfigurer.html[`CachingConfigurer`] javadoc)
|
||||||
| `cacheManager`
|
| `cacheManager`
|
||||||
| The name of the cache manager to use. A default `CacheResolver` is initialized behind
|
| The name of the cache manager to use. A default `CacheResolver` is initialized behind
|
||||||
the scenes with this cache manager (or `cacheManager` if not set). For more
|
the scenes with this cache manager (or `cacheManager` if not set). For more
|
||||||
|
|
@ -583,19 +583,19 @@ required to implement `CachingConfigurer`, see the
|
||||||
attribute.
|
attribute.
|
||||||
|
|
||||||
| `cache-resolver`
|
| `cache-resolver`
|
||||||
| N/A (see the {api-spring-framework}/cache/annotation/CachingConfigurer.html[`CachingConfigurer`] javadoc)
|
| N/A (see the {spring-framework-api}/cache/annotation/CachingConfigurer.html[`CachingConfigurer`] javadoc)
|
||||||
| A `SimpleCacheResolver` using the configured `cacheManager`.
|
| A `SimpleCacheResolver` using the configured `cacheManager`.
|
||||||
| The bean name of the CacheResolver that is to be used to resolve the backing caches.
|
| The bean name of the CacheResolver that is to be used to resolve the backing caches.
|
||||||
This attribute is not required and needs to be specified only as an alternative to
|
This attribute is not required and needs to be specified only as an alternative to
|
||||||
the 'cache-manager' attribute.
|
the 'cache-manager' attribute.
|
||||||
|
|
||||||
| `key-generator`
|
| `key-generator`
|
||||||
| N/A (see the {api-spring-framework}/cache/annotation/CachingConfigurer.html[`CachingConfigurer`] javadoc)
|
| N/A (see the {spring-framework-api}/cache/annotation/CachingConfigurer.html[`CachingConfigurer`] javadoc)
|
||||||
| `SimpleKeyGenerator`
|
| `SimpleKeyGenerator`
|
||||||
| Name of the custom key generator to use.
|
| Name of the custom key generator to use.
|
||||||
|
|
||||||
| `error-handler`
|
| `error-handler`
|
||||||
| N/A (see the {api-spring-framework}/cache/annotation/CachingConfigurer.html[`CachingConfigurer`] javadoc)
|
| N/A (see the {spring-framework-api}/cache/annotation/CachingConfigurer.html[`CachingConfigurer`] javadoc)
|
||||||
| `SimpleCacheErrorHandler`
|
| `SimpleCacheErrorHandler`
|
||||||
| The name of the custom cache error handler to use. By default, any exception thrown during
|
| The name of the custom cache error handler to use. By default, any exception thrown during
|
||||||
a cache related operation is thrown back at the client.
|
a cache related operation is thrown back at the client.
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ interface. A simple value object that encapsulates the properties of a simple ma
|
||||||
as `from` and `to` (plus many others) is the `SimpleMailMessage` class. This package
|
as `from` and `to` (plus many others) is the `SimpleMailMessage` class. This package
|
||||||
also contains a hierarchy of checked exceptions that provide a higher level of
|
also contains a hierarchy of checked exceptions that provide a higher level of
|
||||||
abstraction over the lower level mail system exceptions, with the root exception being
|
abstraction over the lower level mail system exceptions, with the root exception being
|
||||||
`MailException`. See the {api-spring-framework}/mail/MailException.html[javadoc]
|
`MailException`. See the {spring-framework-api}/mail/MailException.html[javadoc]
|
||||||
for more information on the rich mail exception hierarchy.
|
for more information on the rich mail exception hierarchy.
|
||||||
|
|
||||||
The `org.springframework.mail.javamail.JavaMailSender` interface adds specialized
|
The `org.springframework.mail.javamail.JavaMailSender` interface adds specialized
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ You can customize the listener container factory to use for each annotation or y
|
||||||
configure an explicit default by implementing the `JmsListenerConfigurer` interface.
|
configure an explicit default by implementing the `JmsListenerConfigurer` interface.
|
||||||
The default is required only if at least one endpoint is registered without a specific
|
The default is required only if at least one endpoint is registered without a specific
|
||||||
container factory. See the javadoc of classes that implement
|
container factory. See the javadoc of classes that implement
|
||||||
{api-spring-framework}/jms/annotation/JmsListenerConfigurer.html[`JmsListenerConfigurer`]
|
{spring-framework-api}/jms/annotation/JmsListenerConfigurer.html[`JmsListenerConfigurer`]
|
||||||
for details and examples.
|
for details and examples.
|
||||||
|
|
||||||
If you prefer xref:integration/jms/namespace.adoc[XML configuration], you can use the `<jms:annotation-driven>`
|
If you prefer xref:integration/jms/namespace.adoc[XML configuration], you can use the `<jms:annotation-driven>`
|
||||||
|
|
|
||||||
|
|
@ -64,9 +64,9 @@ In some environments, you can instead obtain the entire `ResourceAdapter` object
|
||||||
(by using `<jee:jndi-lookup>`). The Spring-based message listeners can then interact with
|
(by using `<jee:jndi-lookup>`). The Spring-based message listeners can then interact with
|
||||||
the server-hosted `ResourceAdapter`, which also use the server's built-in `WorkManager`.
|
the server-hosted `ResourceAdapter`, which also use the server's built-in `WorkManager`.
|
||||||
|
|
||||||
See the javadoc for {api-spring-framework}/jms/listener/endpoint/JmsMessageEndpointManager.html[`JmsMessageEndpointManager`],
|
See the javadoc for {spring-framework-api}/jms/listener/endpoint/JmsMessageEndpointManager.html[`JmsMessageEndpointManager`],
|
||||||
{api-spring-framework}/jms/listener/endpoint/JmsActivationSpecConfig.html[`JmsActivationSpecConfig`],
|
{spring-framework-api}/jms/listener/endpoint/JmsActivationSpecConfig.html[`JmsActivationSpecConfig`],
|
||||||
and {api-spring-framework}/jca/support/ResourceAdapterFactoryBean.html[`ResourceAdapterFactoryBean`]
|
and {spring-framework-api}/jca/support/ResourceAdapterFactoryBean.html[`ResourceAdapterFactoryBean`]
|
||||||
for more details.
|
for more details.
|
||||||
|
|
||||||
Spring also provides a generic JCA message endpoint manager that is not tied to JMS:
|
Spring also provides a generic JCA message endpoint manager that is not tied to JMS:
|
||||||
|
|
@ -74,7 +74,7 @@ Spring also provides a generic JCA message endpoint manager that is not tied to
|
||||||
for using any message listener type (such as a JMS `MessageListener`) and any
|
for using any message listener type (such as a JMS `MessageListener`) and any
|
||||||
provider-specific `ActivationSpec` object. See your JCA provider's documentation to
|
provider-specific `ActivationSpec` object. See your JCA provider's documentation to
|
||||||
find out about the actual capabilities of your connector, and see the
|
find out about the actual capabilities of your connector, and see the
|
||||||
{api-spring-framework}/jca/endpoint/GenericMessageEndpointManager.html[`GenericMessageEndpointManager`]
|
{spring-framework-api}/jca/endpoint/GenericMessageEndpointManager.html[`GenericMessageEndpointManager`]
|
||||||
javadoc for the Spring-specific configuration details.
|
javadoc for the Spring-specific configuration details.
|
||||||
|
|
||||||
NOTE: JCA-based message endpoint management is very analogous to EJB 2.1 Message-Driven Beans.
|
NOTE: JCA-based message endpoint management is very analogous to EJB 2.1 Message-Driven Beans.
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ as the following example shows:
|
||||||
----
|
----
|
||||||
|
|
||||||
The following table describes all available attributes. See the class-level javadoc
|
The following table describes all available attributes. See the class-level javadoc
|
||||||
of the {api-spring-framework}/jms/listener/AbstractMessageListenerContainer.html[`AbstractMessageListenerContainer`]
|
of the {spring-framework-api}/jms/listener/AbstractMessageListenerContainer.html[`AbstractMessageListenerContainer`]
|
||||||
and its concrete subclasses for more details on the individual properties. The javadoc
|
and its concrete subclasses for more details on the individual properties. The javadoc
|
||||||
also provides a discussion of transaction choices and message redelivery scenarios.
|
also provides a discussion of transaction choices and message redelivery scenarios.
|
||||||
|
|
||||||
|
|
@ -254,7 +254,7 @@ The following table describes the available configuration options for the JCA va
|
||||||
|
|
||||||
| `activation-spec-factory`
|
| `activation-spec-factory`
|
||||||
| A reference to the `JmsActivationSpecFactory`. The default is to autodetect the JMS
|
| A reference to the `JmsActivationSpecFactory`. The default is to autodetect the JMS
|
||||||
provider and its `ActivationSpec` class (see {api-spring-framework}/jms/listener/endpoint/DefaultJmsActivationSpecFactory.html[`DefaultJmsActivationSpecFactory`]).
|
provider and its `ActivationSpec` class (see {spring-framework-api}/jms/listener/endpoint/DefaultJmsActivationSpecFactory.html[`DefaultJmsActivationSpecFactory`]).
|
||||||
|
|
||||||
| `destination-resolver`
|
| `destination-resolver`
|
||||||
| A reference to the `DestinationResolver` strategy for resolving JMS `Destinations`.
|
| A reference to the `DestinationResolver` strategy for resolving JMS `Destinations`.
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ containers that ships with Spring (in this case, `DefaultMessageListenerContaine
|
||||||
----
|
----
|
||||||
|
|
||||||
See the Spring javadoc of the various message listener containers (all of which implement
|
See the Spring javadoc of the various message listener containers (all of which implement
|
||||||
{api-spring-framework}/jms/listener/MessageListenerContainer.html[MessageListenerContainer])
|
{spring-framework-api}/jms/listener/MessageListenerContainer.html[MessageListenerContainer])
|
||||||
for a full description of the features supported by each implementation.
|
for a full description of the features supported by each implementation.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -234,7 +234,7 @@ use a proper cache level in such a case.
|
||||||
This container also has recoverable capabilities when the broker goes down. By default,
|
This container also has recoverable capabilities when the broker goes down. By default,
|
||||||
a simple `BackOff` implementation retries every five seconds. You can specify
|
a simple `BackOff` implementation retries every five seconds. You can specify
|
||||||
a custom `BackOff` implementation for more fine-grained recovery options. See
|
a custom `BackOff` implementation for more fine-grained recovery options. See
|
||||||
{api-spring-framework}/util/backoff/ExponentialBackOff.html[`ExponentialBackOff`] for an example.
|
{spring-framework-api}/util/backoff/ExponentialBackOff.html[`ExponentialBackOff`] for an example.
|
||||||
|
|
||||||
NOTE: Like its sibling (xref:integration/jms/using.adoc#jms-mdp-simple[`SimpleMessageListenerContainer`]),
|
NOTE: Like its sibling (xref:integration/jms/using.adoc#jms-mdp-simple[`SimpleMessageListenerContainer`]),
|
||||||
`DefaultMessageListenerContainer` supports native JMS transactions and allows for
|
`DefaultMessageListenerContainer` supports native JMS transactions and allows for
|
||||||
|
|
|
||||||
|
|
@ -246,7 +246,7 @@ instance. The `NotificationPublisherAware` interface supplies an instance of a
|
||||||
which the bean can then use to publish `Notifications`.
|
which the bean can then use to publish `Notifications`.
|
||||||
|
|
||||||
As stated in the javadoc of the
|
As stated in the javadoc of the
|
||||||
{api-spring-framework}/jmx/export/notification/NotificationPublisher.html[`NotificationPublisher`]
|
{spring-framework-api}/jmx/export/notification/NotificationPublisher.html[`NotificationPublisher`]
|
||||||
interface, managed beans that publish events through the `NotificationPublisher`
|
interface, managed beans that publish events through the `NotificationPublisher`
|
||||||
mechanism are not responsible for the state management of notification listeners.
|
mechanism are not responsible for the state management of notification listeners.
|
||||||
Spring's JMX support takes care of handling all the JMX infrastructure issues.
|
Spring's JMX support takes care of handling all the JMX infrastructure issues.
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,8 @@ This section contains links to further resources about JMX:
|
||||||
|
|
||||||
* The https://www.oracle.com/technetwork/java/javase/tech/javamanagement-140525.html[JMX
|
* The https://www.oracle.com/technetwork/java/javase/tech/javamanagement-140525.html[JMX
|
||||||
homepage] at Oracle.
|
homepage] at Oracle.
|
||||||
* The https://jcp.org/aboutJava/communityprocess/final/jsr003/index3.html[JMX
|
* The {JSR}003[JMX specification] (JSR-000003).
|
||||||
specification] (JSR-000003).
|
* The {JSR}160[JMX Remote API specification] (JSR-000160).
|
||||||
* The https://jcp.org/aboutJava/communityprocess/final/jsr160/index.html[JMX Remote API
|
|
||||||
specification] (JSR-000160).
|
|
||||||
* The http://mx4j.sourceforge.net/[MX4J homepage]. (MX4J is an open-source implementation of
|
* The http://mx4j.sourceforge.net/[MX4J homepage]. (MX4J is an open-source implementation of
|
||||||
various JMX specs.)
|
various JMX specs.)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ Metrics can help you to track error rates, usage patterns, performance, and more
|
||||||
Traces provide a holistic view of an entire system, crossing application boundaries; you can zoom in on particular user requests and follow their entire completion across applications.
|
Traces provide a holistic view of an entire system, crossing application boundaries; you can zoom in on particular user requests and follow their entire completion across applications.
|
||||||
|
|
||||||
Spring Framework instruments various parts of its own codebase to publish observations if an `ObservationRegistry` is configured.
|
Spring Framework instruments various parts of its own codebase to publish observations if an `ObservationRegistry` is configured.
|
||||||
You can learn more about {docs-spring-boot}/html/actuator.html#actuator.metrics[configuring the observability infrastructure in Spring Boot].
|
You can learn more about {spring-boot-docs}/actuator.html#actuator.metrics[configuring the observability infrastructure in Spring Boot].
|
||||||
|
|
||||||
|
|
||||||
[[observability.list]]
|
[[observability.list]]
|
||||||
|
|
|
||||||
|
|
@ -344,7 +344,7 @@ The `spring-web` module contains the `HttpMessageConverter` interface for readin
|
||||||
Concrete implementations for the main media (MIME) types are provided in the framework and are, by default, registered with the `RestClient` and `RestTemplate` on the client side and with `RequestMappingHandlerAdapter` on the server side (see xref:web/webmvc/mvc-config/message-converters.adoc[Configuring Message Converters]).
|
Concrete implementations for the main media (MIME) types are provided in the framework and are, by default, registered with the `RestClient` and `RestTemplate` on the client side and with `RequestMappingHandlerAdapter` on the server side (see xref:web/webmvc/mvc-config/message-converters.adoc[Configuring Message Converters]).
|
||||||
|
|
||||||
Several implementations of `HttpMessageConverter` are described below.
|
Several implementations of `HttpMessageConverter` are described below.
|
||||||
Refer to the {api-spring-framework}/http/converter/HttpMessageConverter.html[`HttpMessageConverter` Javadoc] for the complete list.
|
Refer to the {spring-framework-api}/http/converter/HttpMessageConverter.html[`HttpMessageConverter` Javadoc] for the complete list.
|
||||||
For all converters, a default media type is used, but you can override it by setting the `supportedMediaTypes` property.
|
For all converters, a default media type is used, but you can override it by setting the `supportedMediaTypes` property.
|
||||||
|
|
||||||
[[rest-message-converters-tbl]]
|
[[rest-message-converters-tbl]]
|
||||||
|
|
@ -384,7 +384,7 @@ When you need further control (for cases where custom JSON serializers/deseriali
|
||||||
By default, this converter supports `application/json`.
|
By default, this converter supports `application/json`.
|
||||||
|
|
||||||
| `MappingJackson2XmlHttpMessageConverter`
|
| `MappingJackson2XmlHttpMessageConverter`
|
||||||
| An `HttpMessageConverter` implementation that can read and write XML by using https://github.com/FasterXML/jackson-dataformat-xml[Jackson XML] extension's `XmlMapper`.
|
| An `HttpMessageConverter` implementation that can read and write XML by using {jackson-github-org}/jackson-dataformat-xml[Jackson XML] extension's `XmlMapper`.
|
||||||
You can customize XML mapping as needed through the use of JAXB or Jackson's provided annotations.
|
You can customize XML mapping as needed through the use of JAXB or Jackson's provided annotations.
|
||||||
When you need further control (for cases where custom XML serializers/deserializers need to be provided for specific types), you can inject a custom `XmlMapper` through the `ObjectMapper` property.
|
When you need further control (for cases where custom XML serializers/deserializers need to be provided for specific types), you can inject a custom `XmlMapper` through the `ObjectMapper` property.
|
||||||
By default, this converter supports `application/xml`.
|
By default, this converter supports `application/xml`.
|
||||||
|
|
@ -401,7 +401,7 @@ You can also set the message converters to use explicitly, by using `messageConv
|
||||||
|
|
||||||
==== Jackson JSON Views
|
==== Jackson JSON Views
|
||||||
|
|
||||||
To serialize only a subset of the object properties, you can specify a https://www.baeldung.com/jackson-json-view-annotation[Jackson JSON View], as the following example shows:
|
To serialize only a subset of the object properties, you can specify a {baeldung-blog}/jackson-json-view-annotation[Jackson JSON View], as the following example shows:
|
||||||
|
|
||||||
[source,java,indent=0,subs="verbatim"]
|
[source,java,indent=0,subs="verbatim"]
|
||||||
----
|
----
|
||||||
|
|
|
||||||
|
|
@ -282,8 +282,8 @@ You can pick and choose the relevant annotations for your application. For examp
|
||||||
if you need only support for `@Scheduled`, you can omit `@EnableAsync`. For more
|
if you need only support for `@Scheduled`, you can omit `@EnableAsync`. For more
|
||||||
fine-grained control, you can additionally implement the `SchedulingConfigurer`
|
fine-grained control, you can additionally implement the `SchedulingConfigurer`
|
||||||
interface, the `AsyncConfigurer` interface, or both. See the
|
interface, the `AsyncConfigurer` interface, or both. See the
|
||||||
{api-spring-framework}/scheduling/annotation/SchedulingConfigurer.html[`SchedulingConfigurer`]
|
{spring-framework-api}/scheduling/annotation/SchedulingConfigurer.html[`SchedulingConfigurer`]
|
||||||
and {api-spring-framework}/scheduling/annotation/AsyncConfigurer.html[`AsyncConfigurer`]
|
and {spring-framework-api}/scheduling/annotation/AsyncConfigurer.html[`AsyncConfigurer`]
|
||||||
javadoc for full details.
|
javadoc for full details.
|
||||||
|
|
||||||
If you prefer XML configuration, you can use the `<task:annotation-driven>` element,
|
If you prefer XML configuration, you can use the `<task:annotation-driven>` element,
|
||||||
|
|
@ -722,7 +722,7 @@ In the preceding configuration, a `queue-capacity` value has also been provided.
|
||||||
The configuration of the thread pool should also be considered in light of the
|
The configuration of the thread pool should also be considered in light of the
|
||||||
executor's queue capacity. For the full description of the relationship between pool
|
executor's queue capacity. For the full description of the relationship between pool
|
||||||
size and queue capacity, see the documentation for
|
size and queue capacity, see the documentation for
|
||||||
https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ThreadPoolExecutor.html[`ThreadPoolExecutor`].
|
{java-api}/java.base/java/util/concurrent/ThreadPoolExecutor.html[`ThreadPoolExecutor`].
|
||||||
The main idea is that, when a task is submitted, the executor first tries to use a
|
The main idea is that, when a task is submitted, the executor first tries to use a
|
||||||
free thread if the number of active threads is currently less than the core size.
|
free thread if the number of active threads is currently less than the core size.
|
||||||
If the core size has been reached, the task is added to the queue, as long as its
|
If the core size has been reached, the task is added to the queue, as long as its
|
||||||
|
|
@ -1093,7 +1093,7 @@ we need to set up the `SchedulerFactoryBean`, as the following example shows:
|
||||||
|
|
||||||
More properties are available for the `SchedulerFactoryBean`, such as the calendars used by the
|
More properties are available for the `SchedulerFactoryBean`, such as the calendars used by the
|
||||||
job details, properties to customize Quartz with, and a Spring-provided JDBC DataSource. See
|
job details, properties to customize Quartz with, and a Spring-provided JDBC DataSource. See
|
||||||
the {api-spring-framework}/scheduling/quartz/SchedulerFactoryBean.html[`SchedulerFactoryBean`]
|
the {spring-framework-api}/scheduling/quartz/SchedulerFactoryBean.html[`SchedulerFactoryBean`]
|
||||||
javadoc for more information.
|
javadoc for more information.
|
||||||
|
|
||||||
NOTE: `SchedulerFactoryBean` also recognizes a `quartz.properties` file in the classpath,
|
NOTE: `SchedulerFactoryBean` also recognizes a `quartz.properties` file in the classpath,
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@
|
||||||
= Kotlin
|
= Kotlin
|
||||||
:page-section-summary-toc: 1
|
:page-section-summary-toc: 1
|
||||||
|
|
||||||
https://kotlinlang.org[Kotlin] is a statically typed language that targets the JVM
|
{kotlin-site}[Kotlin] is a statically typed language that targets the JVM
|
||||||
(and other platforms) which allows writing concise and elegant code while providing
|
(and other platforms) which allows writing concise and elegant code while providing
|
||||||
very good https://kotlinlang.org/docs/reference/java-interop.html[interoperability]
|
very good {kotlin-docs}/java-interop.html[interoperability]
|
||||||
with existing libraries written in Java.
|
with existing libraries written in Java.
|
||||||
|
|
||||||
The Spring Framework provides first-class support for Kotlin and lets developers write
|
The Spring Framework provides first-class support for Kotlin and lets developers write
|
||||||
|
|
@ -13,13 +13,13 @@ Most of the code samples of the reference documentation are
|
||||||
provided in Kotlin in addition to Java.
|
provided in Kotlin in addition to Java.
|
||||||
|
|
||||||
The easiest way to build a Spring application with Kotlin is to leverage Spring Boot and
|
The easiest way to build a Spring application with Kotlin is to leverage Spring Boot and
|
||||||
its https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-kotlin.html[dedicated Kotlin support].
|
its{spring-boot-docs}/boot-features-kotlin.html[dedicated Kotlin support].
|
||||||
https://spring.io/guides/tutorials/spring-boot-kotlin/[This comprehensive tutorial]
|
{spring-site-guides}/tutorials/spring-boot-kotlin/[This comprehensive tutorial]
|
||||||
will teach you how to build Spring Boot applications with Kotlin using https://start.spring.io/#!language=kotlin&type=gradle-project[start.spring.io].
|
will teach you how to build Spring Boot applications with Kotlin using https://start.spring.io/#!language=kotlin&type=gradle-project[start.spring.io].
|
||||||
|
|
||||||
Feel free to join the #spring channel of https://slack.kotlinlang.org/[Kotlin Slack]
|
Feel free to join the #spring channel of https://slack.kotlinlang.org/[Kotlin Slack]
|
||||||
or ask a question with `spring` and `kotlin` as tags on
|
or ask a question with `spring` and `kotlin` as tags on
|
||||||
https://stackoverflow.com/questions/tagged/spring+kotlin[Stackoverflow] if you need support.
|
{stackoverflow-spring-kotlin-tags}[Stackoverflow] if you need support.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
[[kotlin-annotations]]
|
[[kotlin-annotations]]
|
||||||
= Annotations
|
= Annotations
|
||||||
|
|
||||||
The Spring Framework also takes advantage of https://kotlinlang.org/docs/reference/null-safety.html[Kotlin null-safety]
|
The Spring Framework also takes advantage of {kotlin-docs}/null-safety.html[Kotlin null-safety]
|
||||||
to determine if an HTTP parameter is required without having to explicitly
|
to determine if an HTTP parameter is required without having to explicitly
|
||||||
define the `required` attribute. That means `@RequestParam name: String?` is treated
|
define the `required` attribute. That means `@RequestParam name: String?` is treated
|
||||||
as not required and, conversely, `@RequestParam name: String` is treated as being required.
|
as not required and, conversely, `@RequestParam name: String` is treated as being required.
|
||||||
|
|
@ -20,9 +20,9 @@ type `Car` may or may not exist. The same behavior applies to autowired construc
|
||||||
|
|
||||||
NOTE: If you use bean validation on classes with properties or a primary constructor
|
NOTE: If you use bean validation on classes with properties or a primary constructor
|
||||||
parameters, you may need to use
|
parameters, you may need to use
|
||||||
https://kotlinlang.org/docs/reference/annotations.html#annotation-use-site-targets[annotation use-site targets],
|
{kotlin-docs}/annotations.html#annotation-use-site-targets[annotation use-site targets],
|
||||||
such as `@field:NotNull` or `@get:Size(min=5, max=15)`, as described in
|
such as `@field:NotNull` or `@get:Size(min=5, max=15)`, as described in
|
||||||
https://stackoverflow.com/a/35853200/1092077[this Stack Overflow response].
|
{stackoverflow-site}/a/35853200/1092077[this Stack Overflow response].
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ the constructor parameters will be autowired by type:
|
||||||
----
|
----
|
||||||
|
|
||||||
In order to allow a more declarative approach and cleaner syntax, Spring Framework provides
|
In order to allow a more declarative approach and cleaner syntax, Spring Framework provides
|
||||||
a {docs-spring-framework}/kdoc-api/spring-context/org.springframework.context.support/-bean-definition-dsl/index.html[Kotlin bean definition DSL]
|
a {spring-framework-api-kdoc}/spring-context/org.springframework.context.support/-bean-definition-dsl/index.html[Kotlin bean definition DSL]
|
||||||
It declares an `ApplicationContextInitializer` through a clean declarative API,
|
It declares an `ApplicationContextInitializer` through a clean declarative API,
|
||||||
which lets you deal with profiles and `Environment` for customizing
|
which lets you deal with profiles and `Environment` for customizing
|
||||||
how beans are registered.
|
how beans are registered.
|
||||||
|
|
@ -104,10 +104,10 @@ as the following example shows:
|
||||||
----
|
----
|
||||||
|
|
||||||
NOTE: Spring Boot is based on JavaConfig and
|
NOTE: Spring Boot is based on JavaConfig and
|
||||||
https://github.com/spring-projects/spring-boot/issues/8115[does not yet provide specific support for functional bean definition],
|
{spring-boot-issues}/8115[does not yet provide specific support for functional bean definition],
|
||||||
but you can experimentally use functional bean definitions through Spring Boot's `ApplicationContextInitializer` support.
|
but you can experimentally use functional bean definitions through Spring Boot's `ApplicationContextInitializer` support.
|
||||||
See https://stackoverflow.com/questions/45935931/how-to-use-functional-bean-definition-kotlin-dsl-with-spring-boot-and-spring-w/46033685#46033685[this Stack Overflow answer]
|
See {stackoverflow-questions}/45935931/how-to-use-functional-bean-definition-kotlin-dsl-with-spring-boot-and-spring-w/46033685#46033685[this Stack Overflow answer]
|
||||||
for more details and up-to-date information. See also the experimental Kofu DSL developed in https://github.com/spring-projects/spring-fu[Spring Fu incubator].
|
for more details and up-to-date information. See also the experimental Kofu DSL developed in {spring-github-org}/spring-fu[Spring Fu incubator].
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ compiler flag to be enabled during compilation. (For completeness, we neverthele
|
||||||
running the Kotlin compiler with its `-java-parameters` flag for standard Java parameter exposure.)
|
running the Kotlin compiler with its `-java-parameters` flag for standard Java parameter exposure.)
|
||||||
|
|
||||||
You can declare configuration classes as
|
You can declare configuration classes as
|
||||||
https://kotlinlang.org/docs/reference/nested-classes.html[top level or nested but not inner],
|
{kotlin-docs}/nested-classes.html[top level or nested but not inner],
|
||||||
since the later requires a reference to the outer class.
|
since the later requires a reference to the outer class.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
[[coroutines]]
|
[[coroutines]]
|
||||||
= Coroutines
|
= Coroutines
|
||||||
|
|
||||||
Kotlin https://kotlinlang.org/docs/reference/coroutines-overview.html[Coroutines] are Kotlin
|
Kotlin {kotlin-docs}/coroutines-overview.html[Coroutines] are Kotlin
|
||||||
lightweight threads allowing to write non-blocking code in an imperative way. On language side,
|
lightweight threads allowing to write non-blocking code in an imperative way. On language side,
|
||||||
suspending functions provides an abstraction for asynchronous operations while on library side
|
suspending functions provides an abstraction for asynchronous operations while on library side
|
||||||
https://github.com/Kotlin/kotlinx.coroutines[kotlinx.coroutines] provides functions like
|
{kotlin-github-org}/kotlinx.coroutines[kotlinx.coroutines] provides functions like
|
||||||
https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/async.html[`async { }`]
|
{kotlin-coroutines-api}/kotlinx-coroutines-core/kotlinx.coroutines/async.html[`async { }`]
|
||||||
and types like https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html[`Flow`].
|
and types like {kotlin-coroutines-api}/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html[`Flow`].
|
||||||
|
|
||||||
Spring Framework provides support for Coroutines on the following scope:
|
Spring Framework provides support for Coroutines on the following scope:
|
||||||
|
|
||||||
* https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-deferred/index.html[Deferred] and https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html[Flow] return values support in Spring MVC and WebFlux annotated `@Controller`
|
* {kotlin-coroutines-api}/kotlinx-coroutines-core/kotlinx.coroutines/-deferred/index.html[Deferred] and {kotlin-coroutines-api}/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html[Flow] return values support in Spring MVC and WebFlux annotated `@Controller`
|
||||||
* Suspending function support in Spring MVC and WebFlux annotated `@Controller`
|
* Suspending function support in Spring MVC and WebFlux annotated `@Controller`
|
||||||
* Extensions for WebFlux {docs-spring-framework}/kdoc-api/spring-webflux/org.springframework.web.reactive.function.client/index.html[client] and {docs-spring-framework}/kdoc-api/spring-webflux/org.springframework.web.reactive.function.server/index.html[server] functional API.
|
* Extensions for WebFlux {spring-framework-api-kdoc}/spring-webflux/org.springframework.web.reactive.function.client/index.html[client] and {spring-framework-api-kdoc}/spring-webflux/org.springframework.web.reactive.function.server/index.html[server] functional API.
|
||||||
* WebFlux.fn {docs-spring-framework}/kdoc-api/spring-webflux/org.springframework.web.reactive.function.server/co-router.html[coRouter { }] DSL
|
* WebFlux.fn {spring-framework-api-kdoc}/spring-webflux/org.springframework.web.reactive.function.server/co-router.html[coRouter { }] DSL
|
||||||
* Suspending function and `Flow` support in RSocket `@MessageMapping` annotated methods
|
* Suspending function and `Flow` support in RSocket `@MessageMapping` annotated methods
|
||||||
* Extensions for {docs-spring-framework}/kdoc-api/spring-messaging/org.springframework.messaging.rsocket/index.html[`RSocketRequester`]
|
* Extensions for {spring-framework-api-kdoc}/spring-messaging/org.springframework.messaging.rsocket/index.html[`RSocketRequester`]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -53,17 +53,17 @@ For input parameters:
|
||||||
* If laziness is not needed, `fun handler(mono: Mono<T>)` becomes `fun handler(value: T)` since a suspending functions can be invoked to get the value parameter.
|
* If laziness is not needed, `fun handler(mono: Mono<T>)` becomes `fun handler(value: T)` since a suspending functions can be invoked to get the value parameter.
|
||||||
* If laziness is needed, `fun handler(mono: Mono<T>)` becomes `fun handler(supplier: suspend () -> T)` or `fun handler(supplier: suspend () -> T?)`
|
* If laziness is needed, `fun handler(mono: Mono<T>)` becomes `fun handler(supplier: suspend () -> T)` or `fun handler(supplier: suspend () -> T?)`
|
||||||
|
|
||||||
https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html[`Flow`] is `Flux` equivalent in Coroutines world, suitable for hot or cold stream, finite or infinite streams, with the following main differences:
|
{kotlin-coroutines-api}/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html[`Flow`] is `Flux` equivalent in Coroutines world, suitable for hot or cold stream, finite or infinite streams, with the following main differences:
|
||||||
|
|
||||||
* `Flow` is push-based while `Flux` is push-pull hybrid
|
* `Flow` is push-based while `Flux` is push-pull hybrid
|
||||||
* Backpressure is implemented via suspending functions
|
* Backpressure is implemented via suspending functions
|
||||||
* `Flow` has only a https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/collect.html[single suspending `collect` method] and operators are implemented as https://kotlinlang.org/docs/reference/extensions.html[extensions]
|
* `Flow` has only a {kotlin-coroutines-api}/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/collect.html[single suspending `collect` method] and operators are implemented as {kotlin-docs}/extensions.html[extensions]
|
||||||
* https://github.com/Kotlin/kotlinx.coroutines/tree/master/kotlinx-coroutines-core/common/src/flow/operators[Operators are easy to implement] thanks to Coroutines
|
* {kotlin-github-org}/kotlinx.coroutines/tree/master/kotlinx-coroutines-core/common/src/flow/operators[Operators are easy to implement] thanks to Coroutines
|
||||||
* Extensions allow to add custom operators to `Flow`
|
* Extensions allow to add custom operators to `Flow`
|
||||||
* Collect operations are suspending functions
|
* Collect operations are suspending functions
|
||||||
* https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/map.html[`map` operator] supports asynchronous operation (no need for `flatMap`) since it takes a suspending function parameter
|
* {kotlin-coroutines-api}/kotlinx-coroutines-core/kotlinx.coroutines.flow/map.html[`map` operator] supports asynchronous operation (no need for `flatMap`) since it takes a suspending function parameter
|
||||||
|
|
||||||
Read this blog post about https://spring.io/blog/2019/04/12/going-reactive-with-spring-coroutines-and-kotlin-flow[Going Reactive with Spring, Coroutines and Kotlin Flow]
|
Read this blog post about {spring-site-blog}/2019/04/12/going-reactive-with-spring-coroutines-and-kotlin-flow[Going Reactive with Spring, Coroutines and Kotlin Flow]
|
||||||
for more details, including how to run code concurrently with Coroutines.
|
for more details, including how to run code concurrently with Coroutines.
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -170,7 +170,7 @@ class CoroutinesViewController(banner: Banner) {
|
||||||
[[webflux-fn]]
|
[[webflux-fn]]
|
||||||
== WebFlux.fn
|
== WebFlux.fn
|
||||||
|
|
||||||
Here is an example of Coroutines router defined via the {docs-spring-framework}/kdoc-api/spring-webflux/org.springframework.web.reactive.function.server/co-router.html[coRouter { }] DSL and related handlers.
|
Here is an example of Coroutines router defined via the {spring-framework-api-kdoc}/spring-webflux/org.springframework.web.reactive.function.server/co-router.html[coRouter { }] DSL and related handlers.
|
||||||
|
|
||||||
[source,kotlin,indent=0]
|
[source,kotlin,indent=0]
|
||||||
----
|
----
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
[[kotlin-extensions]]
|
[[kotlin-extensions]]
|
||||||
= Extensions
|
= Extensions
|
||||||
|
|
||||||
Kotlin https://kotlinlang.org/docs/reference/extensions.html[extensions] provide the ability
|
Kotlin {kotlin-docs}/extensions.html[extensions] provide the ability
|
||||||
to extend existing classes with additional functionality. The Spring Framework Kotlin APIs
|
to extend existing classes with additional functionality. The Spring Framework Kotlin APIs
|
||||||
use these extensions to add new Kotlin-specific conveniences to existing Spring APIs.
|
use these extensions to add new Kotlin-specific conveniences to existing Spring APIs.
|
||||||
|
|
||||||
The {docs-spring-framework}/kdoc-api/[Spring Framework KDoc API] lists
|
The {spring-framework-api-kdoc}/[Spring Framework KDoc API] lists
|
||||||
and documents all available Kotlin extensions and DSLs.
|
and documents all available Kotlin extensions and DSLs.
|
||||||
|
|
||||||
NOTE: Keep in mind that Kotlin extensions need to be imported to be used. This means,
|
NOTE: Keep in mind that Kotlin extensions need to be imported to be used. This means,
|
||||||
|
|
@ -13,8 +13,8 @@ for example, that the `GenericApplicationContext.registerBean` Kotlin extension
|
||||||
is available only if `org.springframework.context.support.registerBean` is imported.
|
is available only if `org.springframework.context.support.registerBean` is imported.
|
||||||
That said, similar to static imports, an IDE should automatically suggest the import in most cases.
|
That said, similar to static imports, an IDE should automatically suggest the import in most cases.
|
||||||
|
|
||||||
For example, https://kotlinlang.org/docs/reference/inline-functions.html#reified-type-parameters[Kotlin reified type parameters]
|
For example, {kotlin-docs}/inline-functions.html#reified-type-parameters[Kotlin reified type parameters]
|
||||||
provide a workaround for JVM https://docs.oracle.com/javase/tutorial/java/generics/erasure.html[generics type erasure],
|
provide a workaround for JVM {java-tutorial}/java/generics/erasure.html[generics type erasure],
|
||||||
and the Spring Framework provides some extensions to take advantage of this feature.
|
and the Spring Framework provides some extensions to take advantage of this feature.
|
||||||
This allows for a better Kotlin API `RestTemplate`, for the new `WebClient` from Spring
|
This allows for a better Kotlin API `RestTemplate`, for the new `WebClient` from Spring
|
||||||
WebFlux, and for various other APIs.
|
WebFlux, and for various other APIs.
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
= Getting Started
|
= Getting Started
|
||||||
|
|
||||||
The easiest way to learn how to build a Spring application with Kotlin is to follow
|
The easiest way to learn how to build a Spring application with Kotlin is to follow
|
||||||
https://spring.io/guides/tutorials/spring-boot-kotlin/[the dedicated tutorial].
|
{spring-site-guides}/tutorials/spring-boot-kotlin/[the dedicated tutorial].
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,20 @@
|
||||||
[[kotlin-null-safety]]
|
[[kotlin-null-safety]]
|
||||||
= Null-safety
|
= Null-safety
|
||||||
|
|
||||||
One of Kotlin's key features is https://kotlinlang.org/docs/reference/null-safety.html[null-safety],
|
One of Kotlin's key features is {kotlin-docs}/null-safety.html[null-safety],
|
||||||
which cleanly deals with `null` values at compile time rather than bumping into the famous
|
which cleanly deals with `null` values at compile time rather than bumping into the famous
|
||||||
`NullPointerException` at runtime. This makes applications safer through nullability
|
`NullPointerException` at runtime. This makes applications safer through nullability
|
||||||
declarations and expressing "`value or no value`" semantics without paying the cost of wrappers, such as `Optional`.
|
declarations and expressing "`value or no value`" semantics without paying the cost of wrappers, such as `Optional`.
|
||||||
(Kotlin allows using functional constructs with nullable values. See this
|
(Kotlin allows using functional constructs with nullable values. See this
|
||||||
https://www.baeldung.com/kotlin-null-safety[comprehensive guide to Kotlin null-safety].)
|
{baeldung-blog}/kotlin-null-safety[comprehensive guide to Kotlin null-safety].)
|
||||||
|
|
||||||
Although Java does not let you express null-safety in its type-system, the Spring Framework
|
Although Java does not let you express null-safety in its type-system, the Spring Framework
|
||||||
provides xref:languages/kotlin/null-safety.adoc[null-safety of the whole Spring Framework API]
|
provides xref:languages/kotlin/null-safety.adoc[null-safety of the whole Spring Framework API]
|
||||||
via tooling-friendly annotations declared in the `org.springframework.lang` package.
|
via tooling-friendly annotations declared in the `org.springframework.lang` package.
|
||||||
By default, types from Java APIs used in Kotlin are recognized as
|
By default, types from Java APIs used in Kotlin are recognized as
|
||||||
https://kotlinlang.org/docs/reference/java-interop.html#null-safety-and-platform-types[platform types],
|
{kotlin-docs}/java-interop.html#null-safety-and-platform-types[platform types],
|
||||||
for which null-checks are relaxed.
|
for which null-checks are relaxed.
|
||||||
https://kotlinlang.org/docs/reference/java-interop.html#jsr-305-support[Kotlin support for JSR-305 annotations]
|
{kotlin-docs}/java-interop.html#jsr-305-support[Kotlin support for JSR-305 annotations]
|
||||||
and Spring nullability annotations provide null-safety for the whole Spring Framework API to Kotlin developers,
|
and Spring nullability annotations provide null-safety for the whole Spring Framework API to Kotlin developers,
|
||||||
with the advantage of dealing with `null`-related issues at compile time.
|
with the advantage of dealing with `null`-related issues at compile time.
|
||||||
|
|
||||||
|
|
@ -30,7 +30,7 @@ API nullability declaration could evolve even between minor releases and that mo
|
||||||
be added in the future.
|
be added in the future.
|
||||||
|
|
||||||
NOTE: Generic type arguments, varargs, and array elements nullability are not supported yet,
|
NOTE: Generic type arguments, varargs, and array elements nullability are not supported yet,
|
||||||
but should be in an upcoming release. See https://github.com/Kotlin/KEEP/issues/79[this discussion]
|
but should be in an upcoming release. See {kotlin-github-org}/KEEP/issues/79[this discussion]
|
||||||
for up-to-date information.
|
for up-to-date information.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,9 @@ and https://search.maven.org/artifact/org.jetbrains.kotlin/kotlin-reflect[`kotli
|
||||||
to be present on the classpath. They are provided by default if you bootstrap a Kotlin project on
|
to be present on the classpath. They are provided by default if you bootstrap a Kotlin project on
|
||||||
https://start.spring.io/#!language=kotlin&type=gradle-project[start.spring.io].
|
https://start.spring.io/#!language=kotlin&type=gradle-project[start.spring.io].
|
||||||
|
|
||||||
WARNING: Kotlin https://kotlinlang.org/docs/inline-classes.html[inline classes] are not yet supported.
|
WARNING: Kotlin {kotlin-docs}/inline-classes.html[inline classes] are not yet supported.
|
||||||
|
|
||||||
NOTE: The https://github.com/FasterXML/jackson-module-kotlin[Jackson Kotlin module] is required
|
NOTE: The {jackson-github-org}/jackson-module-kotlin[Jackson Kotlin module] is required
|
||||||
for serializing or deserializing JSON data for Kotlin classes with Jackson, so make sure to add the
|
for serializing or deserializing JSON data for Kotlin classes with Jackson, so make sure to add the
|
||||||
`com.fasterxml.jackson.module:jackson-module-kotlin` dependency to your project if you have such need.
|
`com.fasterxml.jackson.module:jackson-module-kotlin` dependency to your project if you have such need.
|
||||||
It is automatically registered when found in the classpath.
|
It is automatically registered when found in the classpath.
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@
|
||||||
We recommend the following resources for people learning how to build applications with
|
We recommend the following resources for people learning how to build applications with
|
||||||
Kotlin and the Spring Framework:
|
Kotlin and the Spring Framework:
|
||||||
|
|
||||||
* https://kotlinlang.org/docs/reference/[Kotlin language reference]
|
* {kotlin-docs}[Kotlin language reference]
|
||||||
* https://slack.kotlinlang.org/[Kotlin Slack] (with a dedicated #spring channel)
|
* https://slack.kotlinlang.org/[Kotlin Slack] (with a dedicated #spring channel)
|
||||||
* https://stackoverflow.com/questions/tagged/spring+kotlin[Stackoverflow, with `spring` and `kotlin` tags]
|
* {stackoverflow-spring-kotlin-tags}[Stackoverflow, with `spring` and `kotlin` tags]
|
||||||
* https://play.kotlinlang.org/[Try Kotlin in your browser]
|
* https://play.kotlinlang.org/[Try Kotlin in your browser]
|
||||||
* https://blog.jetbrains.com/kotlin/[Kotlin blog]
|
* https://blog.jetbrains.com/kotlin/[Kotlin blog]
|
||||||
* https://kotlin.link/[Awesome Kotlin]
|
* https://kotlin.link/[Awesome Kotlin]
|
||||||
|
|
@ -34,12 +34,12 @@ The following Github projects offer examples that you can learn from and possibl
|
||||||
The following list categorizes the pending issues related to Spring and Kotlin support:
|
The following list categorizes the pending issues related to Spring and Kotlin support:
|
||||||
|
|
||||||
* Spring Framework
|
* Spring Framework
|
||||||
** https://github.com/spring-projects/spring-framework/issues/20606[Unable to use WebTestClient with mock server in Kotlin]
|
** {spring-framework-issues}/20606[Unable to use WebTestClient with mock server in Kotlin]
|
||||||
** https://github.com/spring-projects/spring-framework/issues/20496[Support null-safety at generics, varargs and array elements level]
|
** {spring-framework-issues}/20496[Support null-safety at generics, varargs and array elements level]
|
||||||
* Kotlin
|
* Kotlin
|
||||||
** https://youtrack.jetbrains.com/issue/KT-6380[Parent issue for Spring Framework support]
|
** {kotlin-issues}/KT-6380[Parent issue for Spring Framework support]
|
||||||
** https://youtrack.jetbrains.com/issue/KT-5464[Kotlin requires type inference where Java doesn't]
|
** {kotlin-issues}/KT-5464[Kotlin requires type inference where Java doesn't]
|
||||||
** https://youtrack.jetbrains.com/issue/KT-20283[Smart cast regression with open classes]
|
** {kotlin-issues}/KT-20283[Smart cast regression with open classes]
|
||||||
** https://youtrack.jetbrains.com/issue/KT-14984[Impossible to pass not all SAM argument as function]
|
** {kotlin-issues}/KT-14984[Impossible to pass not all SAM argument as function]
|
||||||
** https://youtrack.jetbrains.com/issue/KT-15125[Support JSR 223 bindings directly via script variables]
|
** {kotlin-issues}/KT-15125[Support JSR 223 bindings directly via script variables]
|
||||||
** https://youtrack.jetbrains.com/issue/KT-6653[Kotlin properties do not override Java-style getters and setters]
|
** {kotlin-issues}/KT-6653[Kotlin properties do not override Java-style getters and setters]
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,10 @@ member function of Spring beans that are proxied by CGLIB, which can
|
||||||
quickly become painful and is against the Kotlin principle of keeping code concise and predictable.
|
quickly become painful and is against the Kotlin principle of keeping code concise and predictable.
|
||||||
|
|
||||||
NOTE: It is also possible to avoid CGLIB proxies for configuration classes by using `@Configuration(proxyBeanMethods = false)`.
|
NOTE: It is also possible to avoid CGLIB proxies for configuration classes by using `@Configuration(proxyBeanMethods = false)`.
|
||||||
See {api-spring-framework}/context/annotation/Configuration.html#proxyBeanMethods--[`proxyBeanMethods` Javadoc] for more details.
|
See {spring-framework-api}/context/annotation/Configuration.html#proxyBeanMethods--[`proxyBeanMethods` Javadoc] for more details.
|
||||||
|
|
||||||
Fortunately, Kotlin provides a
|
Fortunately, Kotlin provides a
|
||||||
https://kotlinlang.org/docs/reference/compiler-plugins.html#kotlin-spring-compiler-plugin[`kotlin-spring`]
|
{kotlin-docs}/compiler-plugins.html#kotlin-spring-compiler-plugin[`kotlin-spring`]
|
||||||
plugin (a preconfigured version of the `kotlin-allopen` plugin) that automatically opens classes
|
plugin (a preconfigured version of the `kotlin-allopen` plugin) that automatically opens classes
|
||||||
and their member functions for types that are annotated or meta-annotated with one of the following
|
and their member functions for types that are annotated or meta-annotated with one of the following
|
||||||
annotations:
|
annotations:
|
||||||
|
|
@ -59,7 +59,7 @@ within the primary constructor, as in the following example:
|
||||||
class Person(val name: String, val age: Int)
|
class Person(val name: String, val age: Int)
|
||||||
----
|
----
|
||||||
|
|
||||||
You can optionally add https://kotlinlang.org/docs/reference/data-classes.html[the `data` keyword]
|
You can optionally add {kotlin-docs}/data-classes.html[the `data` keyword]
|
||||||
to make the compiler automatically derive the following members from all properties declared
|
to make the compiler automatically derive the following members from all properties declared
|
||||||
in the primary constructor:
|
in the primary constructor:
|
||||||
|
|
||||||
|
|
@ -80,12 +80,12 @@ As the following example shows, this allows for easy changes to individual prope
|
||||||
|
|
||||||
Common persistence technologies (such as JPA) require a default constructor, preventing this
|
Common persistence technologies (such as JPA) require a default constructor, preventing this
|
||||||
kind of design. Fortunately, there is a workaround for this
|
kind of design. Fortunately, there is a workaround for this
|
||||||
https://stackoverflow.com/questions/32038177/kotlin-with-jpa-default-constructor-hell["`default constructor hell`"],
|
{stackoverflow-questions}/32038177/kotlin-with-jpa-default-constructor-hell["`default constructor hell`"],
|
||||||
since Kotlin provides a https://kotlinlang.org/docs/reference/compiler-plugins.html#kotlin-jpa-compiler-plugin[`kotlin-jpa`]
|
since Kotlin provides a {kotlin-docs}/compiler-plugins.html#kotlin-jpa-compiler-plugin[`kotlin-jpa`]
|
||||||
plugin that generates synthetic no-arg constructor for classes annotated with JPA annotations.
|
plugin that generates synthetic no-arg constructor for classes annotated with JPA annotations.
|
||||||
|
|
||||||
If you need to leverage this kind of mechanism for other persistence technologies, you can configure
|
If you need to leverage this kind of mechanism for other persistence technologies, you can configure
|
||||||
the https://kotlinlang.org/docs/reference/compiler-plugins.html#how-to-use-no-arg-plugin[`kotlin-noarg`]
|
the {kotlin-docs}/compiler-plugins.html#how-to-use-no-arg-plugin[`kotlin-noarg`]
|
||||||
plugin.
|
plugin.
|
||||||
|
|
||||||
NOTE: As of the Kay release train, Spring Data supports Kotlin immutable class instances and
|
NOTE: As of the Kay release train, Spring Data supports Kotlin immutable class instances and
|
||||||
|
|
@ -98,7 +98,7 @@ does not require the `kotlin-noarg` plugin if the module uses Spring Data object
|
||||||
== Injecting Dependencies
|
== Injecting Dependencies
|
||||||
|
|
||||||
Our recommendation is to try to favor constructor injection with `val` read-only (and
|
Our recommendation is to try to favor constructor injection with `val` read-only (and
|
||||||
non-nullable when possible) https://kotlinlang.org/docs/reference/properties.html[properties],
|
non-nullable when possible) {kotlin-docs}/properties.html[properties],
|
||||||
as the following example shows:
|
as the following example shows:
|
||||||
|
|
||||||
[source,kotlin,indent=0]
|
[source,kotlin,indent=0]
|
||||||
|
|
@ -137,13 +137,13 @@ as the following example shows:
|
||||||
|
|
||||||
In Java, you can inject configuration properties by using annotations (such as pass:q[`@Value("${property}")`)].
|
In Java, you can inject configuration properties by using annotations (such as pass:q[`@Value("${property}")`)].
|
||||||
However, in Kotlin, `$` is a reserved character that is used for
|
However, in Kotlin, `$` is a reserved character that is used for
|
||||||
https://kotlinlang.org/docs/reference/idioms.html#string-interpolation[string interpolation].
|
{kotlin-docs}/idioms.html#string-interpolation[string interpolation].
|
||||||
|
|
||||||
Therefore, if you wish to use the `@Value` annotation in Kotlin, you need to escape the `$`
|
Therefore, if you wish to use the `@Value` annotation in Kotlin, you need to escape the `$`
|
||||||
character by writing pass:q[`@Value("\${property}")`].
|
character by writing pass:q[`@Value("\${property}")`].
|
||||||
|
|
||||||
NOTE: If you use Spring Boot, you should probably use
|
NOTE: If you use Spring Boot, you should probably use
|
||||||
https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html#boot-features-external-config-typesafe-configuration-properties[`@ConfigurationProperties`]
|
{spring-boot-docs}/boot-features-external-config.html#boot-features-external-config-typesafe-configuration-properties[`@ConfigurationProperties`]
|
||||||
instead of `@Value` annotations.
|
instead of `@Value` annotations.
|
||||||
|
|
||||||
As an alternative, you can customize the property placeholder prefix by declaring the
|
As an alternative, you can customize the property placeholder prefix by declaring the
|
||||||
|
|
@ -177,14 +177,14 @@ that uses the `${...}` syntax, with configuration beans, as the following exampl
|
||||||
[[checked-exceptions]]
|
[[checked-exceptions]]
|
||||||
== Checked Exceptions
|
== Checked Exceptions
|
||||||
|
|
||||||
Java and https://kotlinlang.org/docs/reference/exceptions.html[Kotlin exception handling]
|
Java and {kotlin-docs}/exceptions.html[Kotlin exception handling]
|
||||||
are pretty close, with the main difference being that Kotlin treats all exceptions as
|
are pretty close, with the main difference being that Kotlin treats all exceptions as
|
||||||
unchecked exceptions. However, when using proxied objects (for example classes or methods
|
unchecked exceptions. However, when using proxied objects (for example classes or methods
|
||||||
annotated with `@Transactional`), checked exceptions thrown will be wrapped by default in
|
annotated with `@Transactional`), checked exceptions thrown will be wrapped by default in
|
||||||
an `UndeclaredThrowableException`.
|
an `UndeclaredThrowableException`.
|
||||||
|
|
||||||
To get the original exception thrown like in Java, methods should be annotated with
|
To get the original exception thrown like in Java, methods should be annotated with
|
||||||
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-throws/index.html[`@Throws`]
|
{kotlin-api}/jvm/stdlib/kotlin.jvm/-throws/index.html[`@Throws`]
|
||||||
to specify explicitly the checked exceptions thrown (for example `@Throws(IOException::class)`).
|
to specify explicitly the checked exceptions thrown (for example `@Throws(IOException::class)`).
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -194,7 +194,7 @@ to specify explicitly the checked exceptions thrown (for example `@Throws(IOExce
|
||||||
|
|
||||||
Kotlin annotations are mostly similar to Java annotations, but array attributes (which are
|
Kotlin annotations are mostly similar to Java annotations, but array attributes (which are
|
||||||
extensively used in Spring) behave differently. As explained in the
|
extensively used in Spring) behave differently. As explained in the
|
||||||
https://kotlinlang.org/docs/reference/annotations.html[Kotlin documentation] you can omit
|
{kotlin-docs}/annotations.html[Kotlin documentation] you can omit
|
||||||
the `value` attribute name, unlike other attributes, and specify it as a `vararg` parameter.
|
the `value` attribute name, unlike other attributes, and specify it as a `vararg` parameter.
|
||||||
|
|
||||||
To understand what that means, consider `@RequestMapping` (which is one of the most widely
|
To understand what that means, consider `@RequestMapping` (which is one of the most widely
|
||||||
|
|
@ -240,13 +240,13 @@ be matched, not only the `GET` method.
|
||||||
== Declaration-site variance
|
== Declaration-site variance
|
||||||
|
|
||||||
Dealing with generic types in Spring applications written in Kotlin may require, for some use cases, to understand
|
Dealing with generic types in Spring applications written in Kotlin may require, for some use cases, to understand
|
||||||
Kotlin https://kotlinlang.org/docs/generics.html#declaration-site-variance[declaration-site variance]
|
Kotlin {kotlin-docs}/generics.html#declaration-site-variance[declaration-site variance]
|
||||||
which allows to define the variance when declaring a type, which is not possible in Java which supports only use-site
|
which allows to define the variance when declaring a type, which is not possible in Java which supports only use-site
|
||||||
variance.
|
variance.
|
||||||
|
|
||||||
For example, declaring `List<Foo>` in Kotlin is conceptually equivalent to `java.util.List<? extends Foo>` because
|
For example, declaring `List<Foo>` in Kotlin is conceptually equivalent to `java.util.List<? extends Foo>` because
|
||||||
`kotlin.collections.List` is declared as
|
`kotlin.collections.List` is declared as
|
||||||
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/[`interface List<out E> : kotlin.collections.Collection<E>`].
|
{kotlin-api}/jvm/stdlib/kotlin.collections/-list/[`interface List<out E> : kotlin.collections.Collection<E>`].
|
||||||
|
|
||||||
This needs to be taken into account by using the `out` Kotlin keyword on generic types when using Java classes,
|
This needs to be taken into account by using the `out` Kotlin keyword on generic types when using Java classes,
|
||||||
for example when writing a `org.springframework.core.convert.converter.Converter` from a Kotlin type to a Java type.
|
for example when writing a `org.springframework.core.convert.converter.Converter` from a Kotlin type to a Java type.
|
||||||
|
|
@ -267,7 +267,7 @@ class ListOfAnyConverter : Converter<List<*>, CustomJavaList<*>> {
|
||||||
----
|
----
|
||||||
|
|
||||||
NOTE: Spring Framework does not leverage yet declaration-site variance type information for injecting beans,
|
NOTE: Spring Framework does not leverage yet declaration-site variance type information for injecting beans,
|
||||||
subscribe to https://github.com/spring-projects/spring-framework/issues/22313[spring-framework#22313] to track related
|
subscribe to {spring-framework-issues}/22313[spring-framework#22313] to track related
|
||||||
progresses.
|
progresses.
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -280,7 +280,7 @@ The recommended testing framework is https://junit.org/junit5/[JUnit 5] along wi
|
||||||
https://mockk.io/[Mockk] for mocking.
|
https://mockk.io/[Mockk] for mocking.
|
||||||
|
|
||||||
NOTE: If you are using Spring Boot, see
|
NOTE: If you are using Spring Boot, see
|
||||||
https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-kotlin-testing[this related documentation].
|
{spring-boot-docs}/features.html#features.kotlin.testing[this related documentation].
|
||||||
|
|
||||||
|
|
||||||
[[constructor-injection]]
|
[[constructor-injection]]
|
||||||
|
|
@ -289,7 +289,7 @@ https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-featu
|
||||||
As described in the xref:testing/testcontext-framework/support-classes.adoc#testcontext-junit-jupiter-di[dedicated section],
|
As described in the xref:testing/testcontext-framework/support-classes.adoc#testcontext-junit-jupiter-di[dedicated section],
|
||||||
JUnit Jupiter (JUnit 5) allows constructor injection of beans which is pretty useful with Kotlin
|
JUnit Jupiter (JUnit 5) allows constructor injection of beans which is pretty useful with Kotlin
|
||||||
in order to use `val` instead of `lateinit var`. You can use
|
in order to use `val` instead of `lateinit var`. You can use
|
||||||
{api-spring-framework}/test/context/TestConstructor.html[`@TestConstructor(autowireMode = AutowireMode.ALL)`]
|
{spring-framework-api}/test/context/TestConstructor.html[`@TestConstructor(autowireMode = AutowireMode.ALL)`]
|
||||||
to enable autowiring for all parameters.
|
to enable autowiring for all parameters.
|
||||||
|
|
||||||
NOTE: You can also change the default behavior to `ALL` in a `junit-platform.properties`
|
NOTE: You can also change the default behavior to `ALL` in a `junit-platform.properties`
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,9 @@
|
||||||
|
|
||||||
Spring Framework comes with a Kotlin router DSL available in 3 flavors:
|
Spring Framework comes with a Kotlin router DSL available in 3 flavors:
|
||||||
|
|
||||||
* WebMvc.fn DSL with {docs-spring-framework}/kdoc-api/spring-webmvc/org.springframework.web.servlet.function/router.html[router { }]
|
* WebMvc.fn DSL with {spring-framework-api-kdoc}/spring-webmvc/org.springframework.web.servlet.function/router.html[router { }]
|
||||||
* WebFlux.fn <<web-reactive#webflux-fn, Reactive>> DSL with {docs-spring-framework}/kdoc-api/spring-webflux/org.springframework.web.reactive.function.server/router.html[router { }]
|
* WebFlux.fn <<web-reactive#webflux-fn, Reactive>> DSL with {spring-framework-api-kdoc}/spring-webflux/org.springframework.web.reactive.function.server/router.html[router { }]
|
||||||
* WebFlux.fn <<Coroutines>> DSL with {docs-spring-framework}/kdoc-api/spring-webflux/org.springframework.web.reactive.function.server/co-router.html[coRouter { }]
|
* WebFlux.fn <<Coroutines>> DSL with {spring-framework-api-kdoc}/spring-webflux/org.springframework.web.reactive.function.server/co-router.html[coRouter { }]
|
||||||
|
|
||||||
These DSL let you write clean and idiomatic Kotlin code to build a `RouterFunction` instance as the following example shows:
|
These DSL let you write clean and idiomatic Kotlin code to build a `RouterFunction` instance as the following example shows:
|
||||||
|
|
||||||
|
|
@ -79,12 +79,12 @@ mockMvc.get("/person/{name}", "Lee") {
|
||||||
== Kotlin Script Templates
|
== Kotlin Script Templates
|
||||||
|
|
||||||
Spring Framework provides a
|
Spring Framework provides a
|
||||||
https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/servlet/view/script/ScriptTemplateView.html[`ScriptTemplateView`]
|
{spring-framework-api}/web/servlet/view/script/ScriptTemplateView.html[`ScriptTemplateView`]
|
||||||
which supports https://www.jcp.org/en/jsr/detail?id=223[JSR-223] to render templates by using script engines.
|
which supports {JSR}223[JSR-223] to render templates by using script engines.
|
||||||
|
|
||||||
By leveraging `scripting-jsr223` dependencies, it
|
By leveraging `scripting-jsr223` dependencies, it
|
||||||
is possible to use such feature to render Kotlin-based templates with
|
is possible to use such feature to render Kotlin-based templates with
|
||||||
https://github.com/Kotlin/kotlinx.html[kotlinx.html] DSL or Kotlin multiline interpolated `String`.
|
{kotlin-github-org}/kotlinx.html[kotlinx.html] DSL or Kotlin multiline interpolated `String`.
|
||||||
|
|
||||||
`build.gradle.kts`
|
`build.gradle.kts`
|
||||||
[source,kotlin,indent=0]
|
[source,kotlin,indent=0]
|
||||||
|
|
@ -126,10 +126,10 @@ project for more details.
|
||||||
[[kotlin-multiplatform-serialization]]
|
[[kotlin-multiplatform-serialization]]
|
||||||
== Kotlin multiplatform serialization
|
== Kotlin multiplatform serialization
|
||||||
|
|
||||||
As of Spring Framework 5.3, https://github.com/Kotlin/kotlinx.serialization[Kotlin multiplatform serialization] is
|
As of Spring Framework 5.3, {kotlin-github-org}/kotlinx.serialization[Kotlin multiplatform serialization] is
|
||||||
supported in Spring MVC, Spring WebFlux and Spring Messaging (RSocket). The builtin support currently targets CBOR, JSON, and ProtoBuf formats.
|
supported in Spring MVC, Spring WebFlux and Spring Messaging (RSocket). The builtin support currently targets CBOR, JSON, and ProtoBuf formats.
|
||||||
|
|
||||||
To enable it, follow https://github.com/Kotlin/kotlinx.serialization#setup[those instructions] to add the related dependency and plugin.
|
To enable it, follow {kotlin-github-org}/kotlinx.serialization#setup[those instructions] to add the related dependency and plugin.
|
||||||
With Spring MVC and WebFlux, both Kotlin serialization and Jackson will be configured by default if they are in the classpath since
|
With Spring MVC and WebFlux, both Kotlin serialization and Jackson will be configured by default if they are in the classpath since
|
||||||
Kotlin serialization is designed to serialize only Kotlin classes annotated with `@Serializable`.
|
Kotlin serialization is designed to serialize only Kotlin classes annotated with `@Serializable`.
|
||||||
With Spring Messaging (RSocket), make sure that neither Jackson, GSON or JSONB are in the classpath if you want automatic configuration,
|
With Spring Messaging (RSocket), make sure that neither Jackson, GSON or JSONB are in the classpath if you want automatic configuration,
|
||||||
|
|
|
||||||
|
|
@ -57,18 +57,18 @@ competition with Spring, they are in fact complementary. The Spring programming
|
||||||
model does not embrace the Jakarta EE platform specification; rather, it integrates
|
model does not embrace the Jakarta EE platform specification; rather, it integrates
|
||||||
with carefully selected individual specifications from the traditional EE umbrella:
|
with carefully selected individual specifications from the traditional EE umbrella:
|
||||||
|
|
||||||
* Servlet API (https://jcp.org/en/jsr/detail?id=340[JSR 340])
|
* Servlet API ({JSR}340[JSR 340])
|
||||||
* WebSocket API (https://www.jcp.org/en/jsr/detail?id=356[JSR 356])
|
* WebSocket API ({JSR}356[JSR 356])
|
||||||
* Concurrency Utilities (https://www.jcp.org/en/jsr/detail?id=236[JSR 236])
|
* Concurrency Utilities ({JSR}236[JSR 236])
|
||||||
* JSON Binding API (https://jcp.org/en/jsr/detail?id=367[JSR 367])
|
* JSON Binding API ({JSR}367[JSR 367])
|
||||||
* Bean Validation (https://jcp.org/en/jsr/detail?id=303[JSR 303])
|
* Bean Validation ({JSR}303[JSR 303])
|
||||||
* JPA (https://jcp.org/en/jsr/detail?id=338[JSR 338])
|
* JPA ({JSR}338[JSR 338])
|
||||||
* JMS (https://jcp.org/en/jsr/detail?id=914[JSR 914])
|
* JMS ({JSR}914[JSR 914])
|
||||||
* as well as JTA/JCA setups for transaction coordination, if necessary.
|
* as well as JTA/JCA setups for transaction coordination, if necessary.
|
||||||
|
|
||||||
The Spring Framework also supports the Dependency Injection
|
The Spring Framework also supports the Dependency Injection
|
||||||
(https://www.jcp.org/en/jsr/detail?id=330[JSR 330]) and Common Annotations
|
({JSR}330[JSR 330]) and Common Annotations
|
||||||
(https://jcp.org/en/jsr/detail?id=250[JSR 250]) specifications, which application
|
({JSR}250[JSR 250]) specifications, which application
|
||||||
developers may choose to use instead of the Spring-specific mechanisms provided
|
developers may choose to use instead of the Spring-specific mechanisms provided
|
||||||
by the Spring Framework. Originally, those were based on common `javax` packages.
|
by the Spring Framework. Originally, those were based on common `javax` packages.
|
||||||
|
|
||||||
|
|
@ -89,7 +89,7 @@ and can run on servers (such as Netty) that are not Servlet containers.
|
||||||
Spring continues to innovate and to evolve. Beyond the Spring Framework, there are other
|
Spring continues to innovate and to evolve. Beyond the Spring Framework, there are other
|
||||||
projects, such as Spring Boot, Spring Security, Spring Data, Spring Cloud, Spring Batch,
|
projects, such as Spring Boot, Spring Security, Spring Data, Spring Cloud, Spring Batch,
|
||||||
among others. It’s important to remember that each project has its own source code repository,
|
among others. It’s important to remember that each project has its own source code repository,
|
||||||
issue tracker, and release cadence. See https://spring.io/projects[spring.io/projects] for
|
issue tracker, and release cadence. See {spring-site-projects}[spring.io/projects] for
|
||||||
the complete list of Spring projects.
|
the complete list of Spring projects.
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -125,17 +125,17 @@ clean code structure with no circular dependencies between packages.
|
||||||
== Feedback and Contributions
|
== Feedback and Contributions
|
||||||
|
|
||||||
For how-to questions or diagnosing or debugging issues, we suggest using Stack Overflow. Click
|
For how-to questions or diagnosing or debugging issues, we suggest using Stack Overflow. Click
|
||||||
https://stackoverflow.com/questions/tagged/spring+or+spring-mvc+or+spring-aop+or+spring-jdbc+or+spring-r2dbc+or+spring-transactions+or+spring-annotations+or+spring-jms+or+spring-el+or+spring-test+or+spring+or+spring-orm+or+spring-jmx+or+spring-cache+or+spring-webflux+or+spring-rsocket?tab=Newest[here]
|
{stackoverflow-spring-tag}+or+spring-mvc+or+spring-aop+or+spring-jdbc+or+spring-r2dbc+or+spring-transactions+or+spring-annotations+or+spring-jms+or+spring-el+or+spring-test+or+spring+or+spring-orm+or+spring-jmx+or+spring-cache+or+spring-webflux+or+spring-rsocket?tab=Newest[here]
|
||||||
for a list of the suggested tags to use on Stack Overflow. If you're fairly certain that
|
for a list of the suggested tags to use on Stack Overflow. If you're fairly certain that
|
||||||
there is a problem in the Spring Framework or would like to suggest a feature, please use
|
there is a problem in the Spring Framework or would like to suggest a feature, please use
|
||||||
the https://github.com/spring-projects/spring-framework/issues[GitHub Issues].
|
the {spring-framework-issues}[GitHub Issues].
|
||||||
|
|
||||||
If you have a solution in mind or a suggested fix, you can submit a pull request on
|
If you have a solution in mind or a suggested fix, you can submit a pull request on
|
||||||
https://github.com/spring-projects/spring-framework[Github]. However, please keep in mind
|
{spring-framework-github}[Github]. However, please keep in mind
|
||||||
that, for all but the most trivial issues, we expect a ticket to be filed in the issue
|
that, for all but the most trivial issues, we expect a ticket to be filed in the issue
|
||||||
tracker, where discussions take place and leave a record for future reference.
|
tracker, where discussions take place and leave a record for future reference.
|
||||||
|
|
||||||
For more details see the guidelines at the {spring-framework-main-code}/CONTRIBUTING.md[CONTRIBUTING],
|
For more details see the guidelines at the {spring-framework-code}/CONTRIBUTING.md[CONTRIBUTING],
|
||||||
top-level project page.
|
top-level project page.
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -145,15 +145,15 @@ top-level project page.
|
||||||
== Getting Started
|
== Getting Started
|
||||||
|
|
||||||
If you are just getting started with Spring, you may want to begin using the Spring
|
If you are just getting started with Spring, you may want to begin using the Spring
|
||||||
Framework by creating a https://projects.spring.io/spring-boot/[Spring Boot]-based
|
Framework by creating a {spring-site-projects}/spring-boot/[Spring Boot]-based
|
||||||
application. Spring Boot provides a quick (and opinionated) way to create a
|
application. Spring Boot provides a quick (and opinionated) way to create a
|
||||||
production-ready Spring-based application. It is based on the Spring Framework, favors
|
production-ready Spring-based application. It is based on the Spring Framework, favors
|
||||||
convention over configuration, and is designed to get you up and running as quickly
|
convention over configuration, and is designed to get you up and running as quickly
|
||||||
as possible.
|
as possible.
|
||||||
|
|
||||||
You can use https://start.spring.io/[start.spring.io] to generate a basic project or follow
|
You can use https://start.spring.io/[start.spring.io] to generate a basic project or follow
|
||||||
one of the https://spring.io/guides["Getting Started" guides], such as
|
one of the {spring-site-guides}["Getting Started" guides], such as
|
||||||
https://spring.io/guides/gs/rest-service/[Getting Started Building a RESTful Web Service].
|
{spring-site-guides}/gs/rest-service/[Getting Started Building a RESTful Web Service].
|
||||||
As well as being easier to digest, these guides are very task focused, and most of them
|
As well as being easier to digest, these guides are very task focused, and most of them
|
||||||
are based on Spring Boot. They also cover other projects from the Spring portfolio that
|
are based on Spring Boot. They also cover other projects from the Spring portfolio that
|
||||||
you might want to consider when solving a particular problem.
|
you might want to consider when solving a particular problem.
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ while the above interactions are called "request streams" or simply "requests".
|
||||||
|
|
||||||
These are the key features and benefits of the RSocket protocol:
|
These are the key features and benefits of the RSocket protocol:
|
||||||
|
|
||||||
* https://www.reactive-streams.org/[Reactive Streams] semantics across network boundary --
|
* {reactive-streams-site}/[Reactive Streams] semantics across network boundary --
|
||||||
for streaming requests such as `Request-Stream` and `Channel`, back pressure signals
|
for streaming requests such as `Request-Stream` and `Channel`, back pressure signals
|
||||||
travel between requester and responder, allowing a requester to slow down a responder at
|
travel between requester and responder, allowing a requester to slow down a responder at
|
||||||
the source, hence reducing reliance on network layer congestion control, and the need
|
the source, hence reducing reliance on network layer congestion control, and the need
|
||||||
|
|
@ -38,9 +38,9 @@ the amount of state required.
|
||||||
* Fragmentation and re-assembly of large messages.
|
* Fragmentation and re-assembly of large messages.
|
||||||
* Keepalive (heartbeats).
|
* Keepalive (heartbeats).
|
||||||
|
|
||||||
RSocket has {gh-rsocket}[implementations] in multiple languages. The
|
RSocket has {rsocket-github-org}[implementations] in multiple languages. The
|
||||||
{gh-rsocket-java}[Java library] is built on https://projectreactor.io/[Project Reactor],
|
{rsocket-java}[Java library] is built on {reactor-site}/[Project Reactor],
|
||||||
and https://github.com/reactor/reactor-netty[Reactor Netty] for the transport. That means
|
and {reactor-github-org}/reactor-netty[Reactor Netty] for the transport. That means
|
||||||
signals from Reactive Streams Publishers in your application propagate transparently
|
signals from Reactive Streams Publishers in your application propagate transparently
|
||||||
through RSocket across the network.
|
through RSocket across the network.
|
||||||
|
|
||||||
|
|
@ -50,8 +50,8 @@ through RSocket across the network.
|
||||||
=== The Protocol
|
=== The Protocol
|
||||||
|
|
||||||
One of the benefits of RSocket is that it has well defined behavior on the wire and an
|
One of the benefits of RSocket is that it has well defined behavior on the wire and an
|
||||||
easy to read https://rsocket.io/about/protocol[specification] along with some protocol
|
easy to read {rsocket-site}/about/protocol[specification] along with some protocol
|
||||||
{gh-rsocket}/rsocket/tree/master/Extensions[extensions]. Therefore it is
|
{rsocket-protocol-extensions}[extensions]. Therefore it is
|
||||||
a good idea to read the spec, independent of language implementations and higher level
|
a good idea to read the spec, independent of language implementations and higher level
|
||||||
framework APIs. This section provides a succinct overview to establish some context.
|
framework APIs. This section provides a succinct overview to establish some context.
|
||||||
|
|
||||||
|
|
@ -96,18 +96,18 @@ and therefore only included in the first message on a request, i.e. with one of
|
||||||
|
|
||||||
Protocol extensions define common metadata formats for use in applications:
|
Protocol extensions define common metadata formats for use in applications:
|
||||||
|
|
||||||
* {gh-rsocket-extensions}/CompositeMetadata.md[Composite Metadata]-- multiple,
|
* {rsocket-protocol-extensions}/CompositeMetadata.md[Composite Metadata]-- multiple,
|
||||||
independently formatted metadata entries.
|
independently formatted metadata entries.
|
||||||
* {gh-rsocket-extensions}/Routing.md[Routing] -- the route for a request.
|
* {rsocket-protocol-extensions}/Routing.md[Routing] -- the route for a request.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[rsocket-java]]
|
[[rsocket-java]]
|
||||||
=== Java Implementation
|
=== Java Implementation
|
||||||
|
|
||||||
The {gh-rsocket-java}[Java implementation] for RSocket is built on
|
The {rsocket-java}[Java implementation] for RSocket is built on
|
||||||
https://projectreactor.io/[Project Reactor]. The transports for TCP and WebSocket are
|
{reactor-site}/[Project Reactor]. The transports for TCP and WebSocket are
|
||||||
built on https://github.com/reactor/reactor-netty[Reactor Netty]. As a Reactive Streams
|
built on {reactor-github-org}/reactor-netty[Reactor Netty]. As a Reactive Streams
|
||||||
library, Reactor simplifies the job of implementing the protocol. For applications it is
|
library, Reactor simplifies the job of implementing the protocol. For applications it is
|
||||||
a natural fit to use `Flux` and `Mono` with declarative operators and transparent back
|
a natural fit to use `Flux` and `Mono` with declarative operators and transparent back
|
||||||
pressure support.
|
pressure support.
|
||||||
|
|
@ -117,7 +117,7 @@ features and leaves the application programming model (e.g. RPC codegen vs other
|
||||||
higher level, independent concern.
|
higher level, independent concern.
|
||||||
|
|
||||||
The main contract
|
The main contract
|
||||||
{gh-rsocket-java}/blob/master/rsocket-core/src/main/java/io/rsocket/RSocket.java[io.rsocket.RSocket]
|
{rsocket-java-code}/rsocket-core/src/main/java/io/rsocket/RSocket.java[io.rsocket.RSocket]
|
||||||
models the four request interaction types with `Mono` representing a promise for a
|
models the four request interaction types with `Mono` representing a promise for a
|
||||||
single message, `Flux` a stream of messages, and `io.rsocket.Payload` the actual
|
single message, `Flux` a stream of messages, and `io.rsocket.Payload` the actual
|
||||||
message with access to data and metadata as byte buffers. The `RSocket` contract is used
|
message with access to data and metadata as byte buffers. The `RSocket` contract is used
|
||||||
|
|
@ -127,7 +127,7 @@ requests with. For responding, the application implements `RSocket` to handle re
|
||||||
This is not meant to be a thorough introduction. For the most part, Spring applications
|
This is not meant to be a thorough introduction. For the most part, Spring applications
|
||||||
will not have to use its API directly. However it may be important to see or experiment
|
will not have to use its API directly. However it may be important to see or experiment
|
||||||
with RSocket independent of Spring. The RSocket Java repository contains a number of
|
with RSocket independent of Spring. The RSocket Java repository contains a number of
|
||||||
{gh-rsocket-java}/tree/master/rsocket-examples[sample apps] that
|
{rsocket-java-code}/rsocket-examples[sample apps] that
|
||||||
demonstrate its API and protocol features.
|
demonstrate its API and protocol features.
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -152,7 +152,7 @@ Spring Boot 2.2 supports standing up an RSocket server over TCP or WebSocket, in
|
||||||
the option to expose RSocket over WebSocket in a WebFlux server. There is also client
|
the option to expose RSocket over WebSocket in a WebFlux server. There is also client
|
||||||
support and auto-configuration for an `RSocketRequester.Builder` and `RSocketStrategies`.
|
support and auto-configuration for an `RSocketRequester.Builder` and `RSocketStrategies`.
|
||||||
See the
|
See the
|
||||||
https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-rsocket[RSocket section]
|
{spring-boot-docs}/messaging.html#messaging.rsocket[RSocket section]
|
||||||
in the Spring Boot reference for more details.
|
in the Spring Boot reference for more details.
|
||||||
|
|
||||||
Spring Security 5.2 provides RSocket support.
|
Spring Security 5.2 provides RSocket support.
|
||||||
|
|
@ -222,7 +222,7 @@ established transparently and used.
|
||||||
|
|
||||||
For data, the default mime type is derived from the first configured `Decoder`. For
|
For data, the default mime type is derived from the first configured `Decoder`. For
|
||||||
metadata, the default mime type is
|
metadata, the default mime type is
|
||||||
{gh-rsocket-extensions}/CompositeMetadata.md[composite metadata] which allows multiple
|
{rsocket-protocol-extensions}/CompositeMetadata.md[composite metadata] which allows multiple
|
||||||
metadata value and mime type pairs per request. Typically both don't need to be changed.
|
metadata value and mime type pairs per request. Typically both don't need to be changed.
|
||||||
|
|
||||||
Data and metadata in the `SETUP` frame is optional. On the server side,
|
Data and metadata in the `SETUP` frame is optional. On the server side,
|
||||||
|
|
@ -534,7 +534,7 @@ Kotlin::
|
||||||
======
|
======
|
||||||
|
|
||||||
Extra metadata values can be added if using
|
Extra metadata values can be added if using
|
||||||
{gh-rsocket-extensions}/CompositeMetadata.md[composite metadata] (the default) and if the
|
{rsocket-protocol-extensions}/CompositeMetadata.md[composite metadata] (the default) and if the
|
||||||
values are supported by a registered `Encoder`. For example:
|
values are supported by a registered `Encoder`. For example:
|
||||||
|
|
||||||
[tabs]
|
[tabs]
|
||||||
|
|
@ -663,8 +663,8 @@ Kotlin::
|
||||||
======
|
======
|
||||||
|
|
||||||
`RSocketMessageHandler` supports
|
`RSocketMessageHandler` supports
|
||||||
{gh-rsocket-extensions}/CompositeMetadata.md[composite] and
|
{rsocket-protocol-extensions}/CompositeMetadata.md[composite] and
|
||||||
{gh-rsocket-extensions}/Routing.md[routing] metadata by default. You can set its
|
{rsocket-protocol-extensions}/Routing.md[routing] metadata by default. You can set its
|
||||||
xref:rsocket.adoc#rsocket-metadata-extractor[MetadataExtractor] if you need to switch to a
|
xref:rsocket.adoc#rsocket-metadata-extractor[MetadataExtractor] if you need to switch to a
|
||||||
different mime type or register additional metadata mime types.
|
different mime type or register additional metadata mime types.
|
||||||
|
|
||||||
|
|
@ -954,7 +954,7 @@ xref:rsocket.adoc#rsocket-requester-server[Server Requester] for details.
|
||||||
== MetadataExtractor
|
== MetadataExtractor
|
||||||
|
|
||||||
Responders must interpret metadata.
|
Responders must interpret metadata.
|
||||||
{gh-rsocket-extensions}/CompositeMetadata.md[Composite metadata] allows independently
|
{rsocket-protocol-extensions}/CompositeMetadata.md[Composite metadata] allows independently
|
||||||
formatted metadata values (e.g. for routing, security, tracing) each with its own mime
|
formatted metadata values (e.g. for routing, security, tracing) each with its own mime
|
||||||
type. Applications need a way to configure metadata mime types to support, and a way
|
type. Applications need a way to configure metadata mime types to support, and a way
|
||||||
to access extracted values.
|
to access extracted values.
|
||||||
|
|
@ -965,7 +965,7 @@ in annotated handler methods.
|
||||||
|
|
||||||
`DefaultMetadataExtractor` can be given `Decoder` instances to decode metadata. Out of
|
`DefaultMetadataExtractor` can be given `Decoder` instances to decode metadata. Out of
|
||||||
the box it has built-in support for
|
the box it has built-in support for
|
||||||
{gh-rsocket-extensions}/Routing.md["message/x.rsocket.routing.v0"] which it decodes to
|
{rsocket-protocol-extensions}/Routing.md["message/x.rsocket.routing.v0"] which it decodes to
|
||||||
`String` and saves under the "route" key. For any other mime type you'll need to provide
|
`String` and saves under the "route" key. For any other mime type you'll need to provide
|
||||||
a `Decoder` and register the mime type as follows:
|
a `Decoder` and register the mime type as follows:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ Kotlin::
|
||||||
|
|
||||||
|
|
||||||
See xref:testing/testcontext-framework/ctx-management.adoc[Context Management] as well as the javadoc for
|
See xref:testing/testcontext-framework/ctx-management.adoc[Context Management] as well as the javadoc for
|
||||||
{api-spring-framework}/test/context/junit/jupiter/SpringJUnitConfig.html[`@SpringJUnitConfig`]
|
{spring-framework-api}/test/context/junit/jupiter/SpringJUnitConfig.html[`@SpringJUnitConfig`]
|
||||||
and `@ContextConfiguration` for further details.
|
and `@ContextConfiguration` for further details.
|
||||||
|
|
||||||
[[integration-testing-annotations-junit-jupiter-springjunitwebconfig]]
|
[[integration-testing-annotations-junit-jupiter-springjunitwebconfig]]
|
||||||
|
|
@ -157,9 +157,9 @@ Kotlin::
|
||||||
|
|
||||||
|
|
||||||
See xref:testing/testcontext-framework/ctx-management.adoc[Context Management] as well as the javadoc for
|
See xref:testing/testcontext-framework/ctx-management.adoc[Context Management] as well as the javadoc for
|
||||||
{api-spring-framework}/test/context/junit/jupiter/web/SpringJUnitWebConfig.html[`@SpringJUnitWebConfig`],
|
{spring-framework-api}/test/context/junit/jupiter/web/SpringJUnitWebConfig.html[`@SpringJUnitWebConfig`],
|
||||||
{api-spring-framework}/test/context/ContextConfiguration.html[`@ContextConfiguration`], and
|
{spring-framework-api}/test/context/ContextConfiguration.html[`@ContextConfiguration`], and
|
||||||
{api-spring-framework}/test/context/web/WebAppConfiguration.html[`@WebAppConfiguration`]
|
{spring-framework-api}/test/context/web/WebAppConfiguration.html[`@WebAppConfiguration`]
|
||||||
for further details.
|
for further details.
|
||||||
|
|
||||||
[[integration-testing-annotations-testconstructor]]
|
[[integration-testing-annotations-testconstructor]]
|
||||||
|
|
|
||||||
|
|
@ -305,5 +305,5 @@ Kotlin::
|
||||||
======
|
======
|
||||||
|
|
||||||
For further details, see the
|
For further details, see the
|
||||||
https://github.com/spring-projects/spring-framework/wiki/Spring-Annotation-Programming-Model[Spring Annotation Programming Model]
|
{spring-framework-wiki}/Spring-Annotation-Programming-Model[Spring Annotation Programming Model]
|
||||||
wiki page.
|
wiki page.
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,6 @@ and registering it by using the `resolver` attribute of `@ActiveProfiles`.
|
||||||
|
|
||||||
See xref:testing/testcontext-framework/ctx-management/env-profiles.adoc[Context Configuration with Environment Profiles],
|
See xref:testing/testcontext-framework/ctx-management/env-profiles.adoc[Context Configuration with Environment Profiles],
|
||||||
xref:testing/testcontext-framework/support-classes.adoc#testcontext-junit-jupiter-nested-test-configuration[`@Nested` test class configuration], and the
|
xref:testing/testcontext-framework/support-classes.adoc#testcontext-junit-jupiter-nested-test-configuration[`@Nested` test class configuration], and the
|
||||||
{api-spring-framework}/test/context/ActiveProfiles.html[`@ActiveProfiles`] javadoc for
|
{spring-framework-api}/test/context/ActiveProfiles.html[`@ActiveProfiles`] javadoc for
|
||||||
examples and further details.
|
examples and further details.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,6 @@ Kotlin::
|
||||||
By default, `@ContextCustomizerFactories` provides support for inheriting factories from
|
By default, `@ContextCustomizerFactories` provides support for inheriting factories from
|
||||||
superclasses or enclosing classes. See
|
superclasses or enclosing classes. See
|
||||||
xref:testing/testcontext-framework/support-classes.adoc#testcontext-junit-jupiter-nested-test-configuration[`@Nested` test class configuration] and the
|
xref:testing/testcontext-framework/support-classes.adoc#testcontext-junit-jupiter-nested-test-configuration[`@Nested` test class configuration] and the
|
||||||
{api-spring-framework}/test/context/ContextCustomizerFactories.html[`@ContextCustomizerFactories`
|
{spring-framework-api}/test/context/ContextCustomizerFactories.html[`@ContextCustomizerFactories`
|
||||||
javadoc] for an example and further details.
|
javadoc] for an example and further details.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,6 @@ If you need to merge or override the configuration for a given level of the cont
|
||||||
hierarchy within a test class hierarchy, you must explicitly name that level by supplying
|
hierarchy within a test class hierarchy, you must explicitly name that level by supplying
|
||||||
the same value to the `name` attribute in `@ContextConfiguration` at each corresponding
|
the same value to the `name` attribute in `@ContextConfiguration` at each corresponding
|
||||||
level in the class hierarchy. See xref:testing/testcontext-framework/ctx-management/hierarchies.adoc[Context Hierarchies] and the
|
level in the class hierarchy. See xref:testing/testcontext-framework/ctx-management/hierarchies.adoc[Context Hierarchies] and the
|
||||||
{api-spring-framework}/test/context/ContextHierarchy.html[`@ContextHierarchy`] javadoc
|
{spring-framework-api}/test/context/ContextHierarchy.html[`@ContextHierarchy`] javadoc
|
||||||
for further examples.
|
for further examples.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -257,6 +257,6 @@ Kotlin::
|
||||||
|
|
||||||
|
|
||||||
For further details regarding the `EXHAUSTIVE` and `CURRENT_LEVEL` algorithms, see the
|
For further details regarding the `EXHAUSTIVE` and `CURRENT_LEVEL` algorithms, see the
|
||||||
{api-spring-framework}/test/annotation/DirtiesContext.HierarchyMode.html[`DirtiesContext.HierarchyMode`]
|
{spring-framework-api}/test/annotation/DirtiesContext.HierarchyMode.html[`DirtiesContext.HierarchyMode`]
|
||||||
javadoc.
|
javadoc.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ _dynamic_ properties to be added to the set of `PropertySources` in the `Environ
|
||||||
an `ApplicationContext` loaded for an integration test. Dynamic properties are useful
|
an `ApplicationContext` loaded for an integration test. Dynamic properties are useful
|
||||||
when you do not know the value of the properties upfront – for example, if the properties
|
when you do not know the value of the properties upfront – for example, if the properties
|
||||||
are managed by an external resource such as for a container managed by the
|
are managed by an external resource such as for a container managed by the
|
||||||
https://www.testcontainers.org/[Testcontainers] project.
|
{testcontainers-site}[Testcontainers] project.
|
||||||
|
|
||||||
The following example demonstrates how to register a dynamic property:
|
The following example demonstrates how to register a dynamic property:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,6 @@ _Spring TestContext Framework_ to record all application events that are publish
|
||||||
The recorded events can be accessed via the `ApplicationEvents` API within tests.
|
The recorded events can be accessed via the `ApplicationEvents` API within tests.
|
||||||
|
|
||||||
See xref:testing/testcontext-framework/application-events.adoc[Application Events] and the
|
See xref:testing/testcontext-framework/application-events.adoc[Application Events] and the
|
||||||
{api-spring-framework}/test/context/event/RecordApplicationEvents.html[`@RecordApplicationEvents`
|
{spring-framework-api}/test/context/event/RecordApplicationEvents.html[`@RecordApplicationEvents`
|
||||||
javadoc] for an example and further details.
|
javadoc] for an example and further details.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ Kotlin::
|
||||||
By default, `@TestExecutionListeners` provides support for inheriting listeners from
|
By default, `@TestExecutionListeners` provides support for inheriting listeners from
|
||||||
superclasses or enclosing classes. See
|
superclasses or enclosing classes. See
|
||||||
xref:testing/testcontext-framework/support-classes.adoc#testcontext-junit-jupiter-nested-test-configuration[`@Nested` test class configuration] and the
|
xref:testing/testcontext-framework/support-classes.adoc#testcontext-junit-jupiter-nested-test-configuration[`@Nested` test class configuration] and the
|
||||||
{api-spring-framework}/test/context/TestExecutionListeners.html[`@TestExecutionListeners`
|
{spring-framework-api}/test/context/TestExecutionListeners.html[`@TestExecutionListeners`
|
||||||
javadoc] for an example and further details. If you discover that you need to switch
|
javadoc] for an example and further details. If you discover that you need to switch
|
||||||
back to using the default `TestExecutionListener` implementations, see the note
|
back to using the default `TestExecutionListener` implementations, see the note
|
||||||
in xref:testing/testcontext-framework/tel-config.adoc#testcontext-tel-config-registering-tels[Registering `TestExecutionListener` Implementations].
|
in xref:testing/testcontext-framework/tel-config.adoc#testcontext-tel-config-registering-tels[Registering `TestExecutionListener` Implementations].
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,6 @@ Kotlin::
|
||||||
Note that `@WebAppConfiguration` must be used in conjunction with
|
Note that `@WebAppConfiguration` must be used in conjunction with
|
||||||
`@ContextConfiguration`, either within a single test class or within a test class
|
`@ContextConfiguration`, either within a single test class or within a test class
|
||||||
hierarchy. See the
|
hierarchy. See the
|
||||||
{api-spring-framework}/test/context/web/WebAppConfiguration.html[`@WebAppConfiguration`]
|
{spring-framework-api}/test/context/web/WebAppConfiguration.html[`@WebAppConfiguration`]
|
||||||
javadoc for further details.
|
javadoc for further details.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ See the following resources for more information about testing:
|
||||||
* https://testng.org/[TestNG]: A testing framework inspired by JUnit with added support
|
* https://testng.org/[TestNG]: A testing framework inspired by JUnit with added support
|
||||||
for test groups, data-driven testing, distributed testing, and other features. Supported
|
for test groups, data-driven testing, distributed testing, and other features. Supported
|
||||||
in the xref:testing/testcontext-framework.adoc[Spring TestContext Framework]
|
in the xref:testing/testcontext-framework.adoc[Spring TestContext Framework]
|
||||||
* https://assertj.github.io/doc/[AssertJ]: "Fluent assertions for Java",
|
* {assertj-docs}[AssertJ]: "Fluent assertions for Java",
|
||||||
including support for Java 8 lambdas, streams, and numerous other features.
|
including support for Java 8 lambdas, streams, and numerous other features.
|
||||||
* https://en.wikipedia.org/wiki/Mock_Object[Mock Objects]: Article in Wikipedia.
|
* https://en.wikipedia.org/wiki/Mock_Object[Mock Objects]: Article in Wikipedia.
|
||||||
* http://www.mockobjects.com/[MockObjects.com]: Web site dedicated to mock objects, a
|
* http://www.mockobjects.com/[MockObjects.com]: Web site dedicated to mock objects, a
|
||||||
|
|
@ -24,7 +24,7 @@ See the following resources for more information about testing:
|
||||||
* https://www.dbunit.org/[DbUnit]: JUnit extension (also usable with Ant and Maven) that
|
* https://www.dbunit.org/[DbUnit]: JUnit extension (also usable with Ant and Maven) that
|
||||||
is targeted at database-driven projects and, among other things, puts your database into
|
is targeted at database-driven projects and, among other things, puts your database into
|
||||||
a known state between test runs.
|
a known state between test runs.
|
||||||
* https://www.testcontainers.org/[Testcontainers]: Java library that supports JUnit
|
* {testcontainers-site}[Testcontainers]: Java library that supports JUnit
|
||||||
tests, providing lightweight, throwaway instances of common databases, Selenium web
|
tests, providing lightweight, throwaway instances of common databases, Selenium web
|
||||||
browsers, or anything else that can run in a Docker container.
|
browsers, or anything else that can run in a Docker container.
|
||||||
* https://sourceforge.net/projects/grinder/[The Grinder]: Java load testing framework.
|
* https://sourceforge.net/projects/grinder/[The Grinder]: Java load testing framework.
|
||||||
|
|
|
||||||
|
|
@ -211,5 +211,5 @@ configuration. Check for the support for code completion on static members.
|
||||||
== Further Examples of Client-side REST Tests
|
== Further Examples of Client-side REST Tests
|
||||||
|
|
||||||
Spring MVC Test's own tests include
|
Spring MVC Test's own tests include
|
||||||
{spring-framework-main-code}/spring-test/src/test/java/org/springframework/test/web/client/samples[example
|
{spring-framework-code}/spring-test/src/test/java/org/springframework/test/web/client/samples[example
|
||||||
tests] of client-side REST tests.
|
tests] of client-side REST tests.
|
||||||
|
|
|
||||||
|
|
@ -184,7 +184,7 @@ Kotlin::
|
||||||
+
|
+
|
||||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||||
----
|
----
|
||||||
// Not possible in Kotlin until https://youtrack.jetbrains.com/issue/KT-22208 is fixed
|
// Not possible in Kotlin until {kotlin-issues}/KT-22208 is fixed
|
||||||
----
|
----
|
||||||
======
|
======
|
||||||
|
|
||||||
|
|
@ -192,7 +192,7 @@ Note that common expectations are always applied and cannot be overridden withou
|
||||||
creating a separate `MockMvc` instance.
|
creating a separate `MockMvc` instance.
|
||||||
|
|
||||||
When a JSON response content contains hypermedia links created with
|
When a JSON response content contains hypermedia links created with
|
||||||
https://github.com/spring-projects/spring-hateoas[Spring HATEOAS], you can verify the
|
{spring-github-org}/spring-hateoas[Spring HATEOAS], you can verify the
|
||||||
resulting links by using JsonPath expressions, as the following example shows:
|
resulting links by using JsonPath expressions, as the following example shows:
|
||||||
|
|
||||||
[tabs]
|
[tabs]
|
||||||
|
|
@ -220,7 +220,7 @@ Kotlin::
|
||||||
======
|
======
|
||||||
|
|
||||||
When XML response content contains hypermedia links created with
|
When XML response content contains hypermedia links created with
|
||||||
https://github.com/spring-projects/spring-hateoas[Spring HATEOAS], you can verify the
|
{spring-github-org}/spring-hateoas[Spring HATEOAS], you can verify the
|
||||||
resulting links by using XPath expressions:
|
resulting links by using XPath expressions:
|
||||||
|
|
||||||
[tabs]
|
[tabs]
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ Kotlin::
|
||||||
+
|
+
|
||||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||||
----
|
----
|
||||||
// Not possible in Kotlin until https://youtrack.jetbrains.com/issue/KT-22208 is fixed
|
// Not possible in Kotlin until {kotlin-issues}/KT-22208 is fixed
|
||||||
----
|
----
|
||||||
======
|
======
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ Kotlin::
|
||||||
======
|
======
|
||||||
|
|
||||||
Finally, we can verify that a new message was created successfully. The following
|
Finally, we can verify that a new message was created successfully. The following
|
||||||
assertions use the https://assertj.github.io/doc/[AssertJ] library:
|
assertions use the {assertj-docs}[AssertJ] library:
|
||||||
|
|
||||||
[tabs]
|
[tabs]
|
||||||
======
|
======
|
||||||
|
|
@ -268,7 +268,7 @@ Kotlin::
|
||||||
+
|
+
|
||||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||||
----
|
----
|
||||||
// Not possible in Kotlin until https://youtrack.jetbrains.com/issue/KT-22208 is fixed
|
// Not possible in Kotlin until {kotlin-issues}/KT-22208 is fixed
|
||||||
----
|
----
|
||||||
======
|
======
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -362,7 +362,7 @@ annotation to look up our submit button with a `css` selector (*input[type=submi
|
||||||
--
|
--
|
||||||
|
|
||||||
Finally, we can verify that a new message was created successfully. The following
|
Finally, we can verify that a new message was created successfully. The following
|
||||||
assertions use the https://assertj.github.io/doc/[AssertJ] assertion library:
|
assertions use the {assertj-docs}[AssertJ] assertion library:
|
||||||
|
|
||||||
--
|
--
|
||||||
[tabs]
|
[tabs]
|
||||||
|
|
@ -562,7 +562,7 @@ Kotlin::
|
||||||
+
|
+
|
||||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||||
----
|
----
|
||||||
// Not possible in Kotlin until https://youtrack.jetbrains.com/issue/KT-22208 is fixed
|
// Not possible in Kotlin until {kotlin-issues}/KT-22208 is fixed
|
||||||
----
|
----
|
||||||
======
|
======
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -159,7 +159,7 @@ Kotlin::
|
||||||
+
|
+
|
||||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||||
----
|
----
|
||||||
// Not possible in Kotlin until https://youtrack.jetbrains.com/issue/KT-22208 is fixed
|
// Not possible in Kotlin until {kotlin-issues}/KT-22208 is fixed
|
||||||
----
|
----
|
||||||
======
|
======
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@
|
||||||
:page-section-summary-toc: 1
|
:page-section-summary-toc: 1
|
||||||
|
|
||||||
The framework's own tests include
|
The framework's own tests include
|
||||||
{spring-framework-main-code}/spring-test/src/test/java/org/springframework/test/web/servlet/samples[
|
{spring-framework-code}/spring-test/src/test/java/org/springframework/test/web/servlet/samples[
|
||||||
many sample tests] intended to show how to use MockMvc on its own or through the
|
many sample tests] intended to show how to use MockMvc on its own or through the
|
||||||
{spring-framework-main-code}/spring-test/src/test/java/org/springframework/test/web/servlet/samples/client[
|
{spring-framework-code}/spring-test/src/test/java/org/springframework/test/web/servlet/samples/client[
|
||||||
WebTestClient]. Browse these examples for further ideas.
|
WebTestClient]. Browse these examples for further ideas.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ Kotlin::
|
||||||
+
|
+
|
||||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||||
----
|
----
|
||||||
// Not possible in Kotlin until https://youtrack.jetbrains.com/issue/KT-22208 is fixed
|
// Not possible in Kotlin until {kotlin-issues}/KT-22208 is fixed
|
||||||
----
|
----
|
||||||
======
|
======
|
||||||
|
|
||||||
|
|
@ -53,11 +53,11 @@ Kotlin::
|
||||||
+
|
+
|
||||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||||
----
|
----
|
||||||
// Not possible in Kotlin until https://youtrack.jetbrains.com/issue/KT-22208 is fixed
|
// Not possible in Kotlin until {kotlin-issues}/KT-22208 is fixed
|
||||||
----
|
----
|
||||||
======
|
======
|
||||||
|
|
||||||
See the javadoc for
|
See the javadoc for
|
||||||
{api-spring-framework}/test/web/servlet/setup/ConfigurableMockMvcBuilder.html[`ConfigurableMockMvcBuilder`]
|
{spring-framework-api}/test/web/servlet/setup/ConfigurableMockMvcBuilder.html[`ConfigurableMockMvcBuilder`]
|
||||||
for a list of all MockMvc builder features or use the IDE to explore the available options.
|
for a list of all MockMvc builder features or use the IDE to explore the available options.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ for rendering JSON, XML, and other formats through `@ResponseBody` methods.
|
||||||
|
|
||||||
Alternatively, you may consider the full end-to-end integration testing support from
|
Alternatively, you may consider the full end-to-end integration testing support from
|
||||||
Spring Boot with `@SpringBootTest`. See the
|
Spring Boot with `@SpringBootTest`. See the
|
||||||
{docs-spring-boot}/html/spring-boot-features.html#boot-features-testing[Spring Boot Reference Guide].
|
{spring-boot-docs}/spring-boot-features.html#boot-features-testing[Spring Boot Reference Guide].
|
||||||
|
|
||||||
There are pros and cons for each approach. The options provided in Spring MVC Test are
|
There are pros and cons for each approach. The options provided in Spring MVC Test are
|
||||||
different stops on the scale from classic unit testing to full integration testing. To be
|
different stops on the scale from classic unit testing to full integration testing. To be
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue