mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e6585e0250 |
@@ -17,73 +17,16 @@ asciidoc:
|
||||
# FIXME: the copyright is not removed
|
||||
# FIXME: The package is not renamed
|
||||
chomp: 'all'
|
||||
fold: 'all'
|
||||
include-java: 'example$docs-src/main/java/org/springframework/docs'
|
||||
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
|
||||
spring-framework-main-code: 'https://github.com/spring-projects/spring-framework/tree/main'
|
||||
docs-site: 'https://docs.spring.io'
|
||||
spring-framework-docs-root: '{docs-site}/spring-framework/docs'
|
||||
spring-framework-api: '{spring-framework-docs-root}/{spring-version}/javadoc-api/org/springframework'
|
||||
spring-framework-api-kdoc: '{spring-framework-docs-root}/{spring-version}/kdoc-api'
|
||||
spring-framework-reference: '{spring-framework-docs-root}/{spring-version}/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: "{docs-site}/spring-framework/docs/{spring-version}"
|
||||
docs-spring-framework: '{docs-site}/spring-framework/docs/{spring-version}'
|
||||
api-spring-framework: '{docs-spring-framework}/javadoc-api/org/springframework'
|
||||
docs-graalvm: 'https://www.graalvm.org/22.3/reference-manual'
|
||||
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'
|
||||
docs-spring-session: '{docs-site}/spring-session/reference'
|
||||
#
|
||||
# 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'
|
||||
gh-rsocket: 'https://github.com/rsocket'
|
||||
gh-rsocket-extensions: '{gh-rsocket}/rsocket/blob/master/Extensions'
|
||||
gh-rsocket-java: '{gh-rsocket}/rsocket-java{gh-rsocket}/rsocket-java'
|
||||
@@ -421,7 +421,6 @@
|
||||
*** xref:integration/cache/specific-config.adoc[]
|
||||
** xref:integration/observability.adoc[]
|
||||
** xref:integration/checkpoint-restore.adoc[]
|
||||
** xref:integration/class-data-sharing.adoc[]
|
||||
** xref:integration/appendix.adoc[]
|
||||
* xref:languages.adoc[]
|
||||
** xref:languages/kotlin.adoc[]
|
||||
@@ -439,4 +438,4 @@
|
||||
** xref:languages/groovy.adoc[]
|
||||
** xref:languages/dynamic.adoc[]
|
||||
* xref:appendix.adoc[]
|
||||
* {spring-framework-wiki}[Wiki]
|
||||
* https://github.com/spring-projects/spring-framework/wiki[Wiki]
|
||||
@@ -8,7 +8,7 @@ within the core Spring Framework.
|
||||
[[appendix-spring-properties]]
|
||||
== Spring Properties
|
||||
|
||||
{spring-framework-api}/core/SpringProperties.html[`SpringProperties`] is a static holder
|
||||
{api-spring-framework}/core/SpringProperties.html[`SpringProperties`] is a static holder
|
||||
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
|
||||
`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`
|
||||
| Instructs Spring to use the `Introspector.IGNORE_ALL_BEANINFO` mode when calling the
|
||||
JavaBeans `Introspector`. See
|
||||
{spring-framework-api}++/beans/StandardBeanInfoFactory.html#IGNORE_BEANINFO_PROPERTY_NAME++[`CachedIntrospectionResults`]
|
||||
{api-spring-framework}++/beans/StandardBeanInfoFactory.html#IGNORE_BEANINFO_PROPERTY_NAME++[`CachedIntrospectionResults`]
|
||||
for details.
|
||||
|
||||
| `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
|
||||
`Environment` property -- for example, a placeholder in a configuration String -- isn't
|
||||
resolvable otherwise. See
|
||||
{spring-framework-api}++/core/env/AbstractEnvironment.html#IGNORE_GETENV_PROPERTY_NAME++[`AbstractEnvironment`]
|
||||
{api-spring-framework}++/core/env/AbstractEnvironment.html#IGNORE_GETENV_PROPERTY_NAME++[`AbstractEnvironment`]
|
||||
for details.
|
||||
|
||||
| `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
|
||||
where nothing is ever to be found for such JNDI fallback searches to begin with, avoiding
|
||||
the repeated JNDI lookup overhead. See
|
||||
{spring-framework-api}++/jndi/JndiLocatorDelegate.html#IGNORE_JNDI_PROPERTY_NAME++[`JndiLocatorDelegate`]
|
||||
{api-spring-framework}++/jndi/JndiLocatorDelegate.html#IGNORE_JNDI_PROPERTY_NAME++[`JndiLocatorDelegate`]
|
||||
for details.
|
||||
|
||||
| `spring.objenesis.ignore`
|
||||
| Instructs Spring to ignore Objenesis, not even attempting to use it. See
|
||||
{spring-framework-api}++/objenesis/SpringObjenesis.html#IGNORE_OBJENESIS_PROPERTY_NAME++[`SpringObjenesis`]
|
||||
{api-spring-framework}++/objenesis/SpringObjenesis.html#IGNORE_OBJENESIS_PROPERTY_NAME++[`SpringObjenesis`]
|
||||
for details.
|
||||
|
||||
| `spring.test.aot.processing.failOnError`
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
// 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
|
||||
`org.aopalliance.aop.Advice` marker interface.
|
||||
|
||||
See the {spring-framework-api}/aop/framework/adapter/package-summary.html[`org.springframework.aop.framework.adapter`]
|
||||
See the {api-spring-framework}/aop/framework/adapter/package-summary.html[`org.springframework.aop.framework.adapter`]
|
||||
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
|
||||
prototype. This lets the `PoolingTargetSource` implementation create new instances
|
||||
of the target to grow the pool as necessary. See the {spring-framework-api}/aop/target/AbstractPoolingTargetSource.html[javadoc of
|
||||
of the target to grow the pool as necessary. See the {api-spring-framework}/aop/target/AbstractPoolingTargetSource.html[javadoc of
|
||||
`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.
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ Kotlin::
|
||||
----
|
||||
======
|
||||
|
||||
See the {spring-framework-api}/aop/aspectj/annotation/AspectJProxyFactory.html[javadoc] for more information.
|
||||
See the {api-spring-framework}/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
|
||||
annotations. The @AspectJ style was introduced by the
|
||||
{aspectj-site}[AspectJ project] as part of the AspectJ 5 release. Spring
|
||||
https://www.eclipse.org/aspectj[AspectJ project] as part of the AspectJ 5 release. Spring
|
||||
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
|
||||
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.
|
||||
* `toString()`: Prints a useful description of the method being advised.
|
||||
|
||||
See the {aspectj-api}/org/aspectj/lang/JoinPoint.html[javadoc] for more detail.
|
||||
See the https://www.eclipse.org/aspectj/doc/released/runtime-api/org/aspectj/lang/JoinPoint.html[javadoc] for more detail.
|
||||
|
||||
[[aop-ataspectj-advice-params-passing]]
|
||||
=== 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+.
|
||||
`AspectJAdviceParameterNameDiscoverer` :: Deduces parameter names from the pointcut
|
||||
expression, `returning`, and `throwing` clauses. See the
|
||||
{spring-framework-api}/aop/aspectj/AspectJAdviceParameterNameDiscoverer.html[javadoc]
|
||||
{api-spring-framework}/aop/aspectj/AspectJAdviceParameterNameDiscoverer.html[javadoc]
|
||||
for details on the algorithm used.
|
||||
|
||||
[[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
|
||||
AspectJ pointcut expression. For a full discussion of AspectJ's pointcut language, see
|
||||
the {aspectj-docs-progguide}/index.html[AspectJ
|
||||
the https://www.eclipse.org/aspectj/doc/released/progguide/index.html[AspectJ
|
||||
Programming Guide] (and, for extensions, the
|
||||
{aspectj-docs}/adk15notebook/index.html[AspectJ 5
|
||||
https://www.eclipse.org/aspectj/doc/released/adk15notebook/index.html[AspectJ 5
|
||||
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).
|
||||
|
||||
@@ -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.
|
||||
`(*,String)` matches a method that takes two parameters. The first can be of any type, while the
|
||||
second must be a `String`. Consult the
|
||||
{aspectj-docs-progguide}/semantics-pointcuts.html[Language
|
||||
https://www.eclipse.org/aspectj/doc/released/progguide/semantics-pointcuts.html[Language
|
||||
Semantics] section of the AspectJ Programming Guide for more information.
|
||||
|
||||
The following examples show some common pointcut expressions:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
= Further Resources
|
||||
:page-section-summary-toc: 1
|
||||
|
||||
More information on AspectJ can be found on the {aspectj-site}[AspectJ website].
|
||||
More information on AspectJ can be found on the https://www.eclipse.org/aspectj[AspectJ website].
|
||||
|
||||
_Eclipse AspectJ_ by Adrian Colyer et. al. (Addison-Wesley, 2005) provides a
|
||||
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
|
||||
with the `new` operator) as well as to `Serializable` objects that are undergoing
|
||||
deserialization (for example, through
|
||||
{java-api}/java.base/java/io/Serializable.html[readResolve()]).
|
||||
https://docs.oracle.com/javase/8/docs/api/java/io/Serializable.html[readResolve()]).
|
||||
|
||||
[NOTE]
|
||||
=====
|
||||
@@ -168,13 +168,14 @@ Kotlin::
|
||||
|
||||
You can find more information about the language semantics of the various pointcut
|
||||
types in AspectJ
|
||||
{aspectj-docs-progguide}/semantics-joinPoints.html[in this appendix] of the
|
||||
{aspectj-docs-progguide}/index.html[AspectJ Programming Guide].
|
||||
https://www.eclipse.org/aspectj/doc/next/progguide/semantics-joinPoints.html[in this
|
||||
appendix] of the https://www.eclipse.org/aspectj/doc/next/progguide/index.html[AspectJ
|
||||
Programming Guide].
|
||||
=====
|
||||
|
||||
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
|
||||
{aspectj-docs-devguide}/antTasks.html[AspectJ Development
|
||||
https://www.eclipse.org/aspectj/doc/released/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
|
||||
`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
|
||||
@@ -398,7 +399,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
|
||||
the specifics of LTW and configuring LTW with only AspectJ (with Spring not being
|
||||
involved at all), see the
|
||||
{aspectj-docs-devguide}/ltw.html[LTW section of the AspectJ
|
||||
https://www.eclipse.org/aspectj/doc/released/devguide/ltw.html[LTW section of the AspectJ
|
||||
Development Environment Guide].
|
||||
|
||||
The value that the Spring Framework brings to AspectJ LTW is in enabling much
|
||||
@@ -420,7 +421,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
|
||||
LTW that uses Spring, followed by detailed specifics about elements introduced in the
|
||||
example. For a complete example, see the
|
||||
{spring-github-org}/spring-petclinic[Petclinic sample application].
|
||||
https://github.com/spring-projects/spring-petclinic[Petclinic sample application].
|
||||
|
||||
|
||||
[[aop-aj-ltw-first-example]]
|
||||
@@ -620,7 +621,7 @@ java -javaagent:C:/projects/xyz/lib/spring-instrument.jar com.xyz.Main
|
||||
----
|
||||
|
||||
The `-javaagent` is a flag for specifying and enabling
|
||||
{java-api}/java.instrument/java/lang/instrument/package-summary.html[agents
|
||||
https://docs.oracle.com/javase/8/docs/api/java/lang/instrument/package-summary.html[agents
|
||||
to instrument programs that run on the JVM]. The Spring Framework ships with such an
|
||||
agent, the `InstrumentationSavingAgent`, which is packaged in the
|
||||
`spring-instrument.jar` that was supplied as the value of the `-javaagent` argument in
|
||||
@@ -720,7 +721,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).
|
||||
|
||||
The structure and contents of this file is detailed in the LTW part of the
|
||||
{aspectj-docs-devguide}/ltw-configuration.html[AspectJ reference
|
||||
https://www.eclipse.org/aspectj/doc/released/devguide/ltw-configuration.html[AspectJ reference
|
||||
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:
|
||||
** `@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.
|
||||
* 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).
|
||||
* 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).
|
||||
* Make sure that the bean type is as precise as possible.
|
||||
|
||||
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
|
||||
* Bytecode (usually for dynamic proxies)
|
||||
* {spring-framework-api}/aot/hint/RuntimeHints.html[`RuntimeHints`] for the use of reflection, resource loading, serialization, and JDK proxies.
|
||||
* {api-spring-framework}/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.
|
||||
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 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 {spring-framework-api}/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 {api-spring-framework}/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.
|
||||
* 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]]
|
||||
== Bean Factory Initialization AOT Contributions
|
||||
|
||||
Components that want to participate in this step can implement the {spring-framework-api}/beans/factory/aot/BeanFactoryInitializationAotProcessor.html[`BeanFactoryInitializationAotProcessor`] interface.
|
||||
Components that want to participate in this step can implement the {api-spring-framework}/beans/factory/aot/BeanFactoryInitializationAotProcessor.html[`BeanFactoryInitializationAotProcessor`] interface.
|
||||
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.
|
||||
@@ -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.
|
||||
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 {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.
|
||||
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.
|
||||
|
||||
[[aot.bestpractices.factory-bean]]
|
||||
=== 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.
|
||||
Consequently, if the application needs to load a resource, it must be referenced from the corresponding GraalVM native image configuration file.
|
||||
|
||||
The {spring-framework-api}/aot/hint/RuntimeHints.html[`RuntimeHints`] API collects the need for reflection, resource loading, serialization, and JDK proxies at runtime.
|
||||
The {api-spring-framework}/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:
|
||||
|
||||
[tabs]
|
||||
@@ -417,7 +417,7 @@ It is also possible to register an implementation statically by adding an entry
|
||||
[[aot.hints.reflective]]
|
||||
=== `@Reflective`
|
||||
|
||||
{spring-framework-api}/aot/hint/annotation/Reflective.html[`@Reflective`] provides an idiomatic way to flag the need for reflection on an annotated element.
|
||||
{api-spring-framework}/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.
|
||||
|
||||
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]]
|
||||
=== `@RegisterReflectionForBinding`
|
||||
|
||||
{spring-framework-api}/aot/hint/annotation/RegisterReflectionForBinding.html[`@RegisterReflectionForBinding`] is a specialization of `@Reflective` that registers the need for serializing arbitrary types.
|
||||
{api-spring-framework}/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.
|
||||
|
||||
`@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.
|
||||
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 {graalvm-docs}/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 {docs-graalvm}/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.
|
||||
|
||||
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.
|
||||
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-code}/buildSrc/README.md[Spring Framework `buildSrc` README] file.
|
||||
You'll find more details in the {spring-framework-main-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
|
||||
service object that (unknown to it) accesses a clustered
|
||||
{JSR}107[JCache], and you want to ensure that the
|
||||
https://jcp.org/en/jsr/detail?id=107[JCache], and you want to ensure that the
|
||||
named JCache instance is eagerly started within the surrounding cluster.
|
||||
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]]
|
||||
==== Setting a Bean Property or Constructor Argument from a Field Value
|
||||
|
||||
{spring-framework-api}/beans/factory/config/FieldRetrievingFactoryBean.html[`FieldRetrievingFactoryBean`]
|
||||
{api-spring-framework}/beans/factory/config/FieldRetrievingFactoryBean.html[`FieldRetrievingFactoryBean`]
|
||||
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
|
||||
property value or constructor argument for another bean.
|
||||
|
||||
The following example shows how a `static` field is exposed, by using the
|
||||
{spring-framework-api}/beans/factory/config/FieldRetrievingFactoryBean.html#setStaticField(java.lang.String)[`staticField`]
|
||||
{api-spring-framework}/beans/factory/config/FieldRetrievingFactoryBean.html#setStaticField(java.lang.String)[`staticField`]
|
||||
property:
|
||||
|
||||
[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
|
||||
described in the API documentation for the
|
||||
{spring-framework-api}/beans/factory/config/FieldRetrievingFactoryBean.html[`FieldRetrievingFactoryBean`]
|
||||
{api-spring-framework}/beans/factory/config/FieldRetrievingFactoryBean.html[`FieldRetrievingFactoryBean`]
|
||||
class.
|
||||
|
||||
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
|
||||
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
|
||||
{spring-site-tools}[Spring Tools] for Eclipse, Visual Studio Code, and Theia.
|
||||
https://spring.io/tools[Spring Tools] for Eclipse, Visual Studio Code, and Theia.
|
||||
****
|
||||
|
||||
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:
|
||||
|
||||
* {spring-framework-api}/context/annotation/ConfigurationClassPostProcessor.html[`ConfigurationClassPostProcessor`]
|
||||
* {spring-framework-api}/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.html[`AutowiredAnnotationBeanPostProcessor`]
|
||||
* {spring-framework-api}/context/annotation/CommonAnnotationBeanPostProcessor.html[`CommonAnnotationBeanPostProcessor`]
|
||||
* {spring-framework-api}/orm/jpa/support/PersistenceAnnotationBeanPostProcessor.html[`PersistenceAnnotationBeanPostProcessor`]
|
||||
* {spring-framework-api}/context/event/EventListenerMethodProcessor.html[`EventListenerMethodProcessor`]
|
||||
* {api-spring-framework}/context/annotation/ConfigurationClassPostProcessor.html[`ConfigurationClassPostProcessor`]
|
||||
* {api-spring-framework}/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.html[`AutowiredAnnotationBeanPostProcessor`]
|
||||
* {api-spring-framework}/context/annotation/CommonAnnotationBeanPostProcessor.html[`CommonAnnotationBeanPostProcessor`]
|
||||
* {api-spring-framework}/orm/jpa/support/PersistenceAnnotationBeanPostProcessor.html[`PersistenceAnnotationBeanPostProcessor`]
|
||||
* {api-spring-framework}/context/event/EventListenerMethodProcessor.html[`EventListenerMethodProcessor`]
|
||||
|
||||
[NOTE]
|
||||
====
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
[[beans-custom-autowire-configurer]]
|
||||
= Using `CustomAutowireConfigurer`
|
||||
|
||||
{spring-framework-api}/beans/factory/annotation/CustomAutowireConfigurer.html[`CustomAutowireConfigurer`]
|
||||
{api-spring-framework}/beans/factory/annotation/CustomAutowireConfigurer.html[`CustomAutowireConfigurer`]
|
||||
is a `BeanFactoryPostProcessor` that lets you register your own custom qualifier
|
||||
annotation types, even if they are not annotated with Spring's `@Qualifier` annotation.
|
||||
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
|
||||
`ApplicationContext` of which the `CommonAnnotationBeanPostProcessor` is aware.
|
||||
The names can be resolved through JNDI if you configure Spring's
|
||||
{spring-framework-api}/jndi/support/SimpleJndiBeanFactory.html[`SimpleJndiBeanFactory`]
|
||||
{api-spring-framework}/jndi/support/SimpleJndiBeanFactory.html[`SimpleJndiBeanFactory`]
|
||||
explicitly. However, we recommend that you rely on the default behavior and
|
||||
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
|
||||
with Spring. In stand-alone applications, it is common to create an
|
||||
instance of
|
||||
{spring-framework-api}/context/support/ClassPathXmlApplicationContext.html[`ClassPathXmlApplicationContext`]
|
||||
or {spring-framework-api}/context/support/FileSystemXmlApplicationContext.html[`FileSystemXmlApplicationContext`].
|
||||
{api-spring-framework}/context/support/ClassPathXmlApplicationContext.html[`ClassPathXmlApplicationContext`]
|
||||
or {api-spring-framework}/context/support/FileSystemXmlApplicationContext.html[`FileSystemXmlApplicationContext`].
|
||||
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
|
||||
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
|
||||
of the application typically suffices (see
|
||||
xref:core/beans/context-introduction.adoc#context-create[Convenient ApplicationContext Instantiation for Web Applications]).
|
||||
If you use the {spring-site-tools}[Spring Tools for Eclipse] (an Eclipse-powered
|
||||
If you use the https://spring.io/tools[Spring Tools for Eclipse] (an Eclipse-powered
|
||||
development environment), you can easily create this boilerplate configuration with a
|
||||
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.
|
||||
* 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
|
||||
{spring-framework-api}/context/annotation/Configuration.html[`@Configuration`],
|
||||
{spring-framework-api}/context/annotation/Bean.html[`@Bean`],
|
||||
{spring-framework-api}/context/annotation/Import.html[`@Import`],
|
||||
and {spring-framework-api}/context/annotation/DependsOn.html[`@DependsOn`] annotations.
|
||||
{api-spring-framework}/context/annotation/Configuration.html[`@Configuration`],
|
||||
{api-spring-framework}/context/annotation/Bean.html[`@Bean`],
|
||||
{api-spring-framework}/context/annotation/Import.html[`@Import`],
|
||||
and {api-spring-framework}/context/annotation/DependsOn.html[`@DependsOn`] annotations.
|
||||
|
||||
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
|
||||
|
||||
@@ -191,7 +191,7 @@ Kotlin::
|
||||
======
|
||||
|
||||
For further details, see the
|
||||
{spring-framework-wiki}/Spring-Annotation-Programming-Model[Spring Annotation Programming Model]
|
||||
https://github.com/spring-projects/spring-framework/wiki/Spring-Annotation-Programming-Model[Spring Annotation Programming Model]
|
||||
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
|
||||
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
|
||||
{stackoverflow-questions}/19394570/java-jre-7u45-breaks-classloader-getresources).
|
||||
https://stackoverflow.com/questions/19394570/java-jre-7u45-breaks-classloader-getresources).
|
||||
|
||||
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`
|
||||
@@ -743,7 +743,7 @@ Kotlin::
|
||||
|
||||
If you do not want to rely on the default bean-naming strategy, you can provide a custom
|
||||
bean-naming strategy. First, implement the
|
||||
{spring-framework-api}/beans/factory/support/BeanNameGenerator.html[`BeanNameGenerator`]
|
||||
{api-spring-framework}/beans/factory/support/BeanNameGenerator.html[`BeanNameGenerator`]
|
||||
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
|
||||
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
|
||||
annotation-based approach, you can implement the
|
||||
{spring-framework-api}/context/annotation/ScopeMetadataResolver.html[`ScopeMetadataResolver`]
|
||||
{api-spring-framework}/context/annotation/ScopeMetadataResolver.html[`ScopeMetadataResolver`]
|
||||
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
|
||||
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`
|
||||
package provides basic functionality for managing and manipulating beans, including in a
|
||||
programmatic way. The `org.springframework.context` package adds the
|
||||
{spring-framework-api}/context/ApplicationContext.html[`ApplicationContext`]
|
||||
{api-spring-framework}/context/ApplicationContext.html[`ApplicationContext`]
|
||||
interface, which extends the `BeanFactory` interface, in addition to extending other
|
||||
interfaces to provide additional functionality in a more application
|
||||
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
|
||||
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).
|
||||
See the {spring-framework-api}/context/support/ReloadableResourceBundleMessageSource.html[`ReloadableResourceBundleMessageSource`]
|
||||
See the {api-spring-framework}/context/support/ReloadableResourceBundleMessageSource.html[`ReloadableResourceBundleMessageSource`]
|
||||
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,
|
||||
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,
|
||||
see the javadoc for Spring's {spring-framework-api}/context/event/ApplicationEventMulticaster.html[`ApplicationEventMulticaster`] interface
|
||||
and {spring-framework-api}/context/event/SimpleApplicationEventMulticaster.html[`SimpleApplicationEventMulticaster`] implementation
|
||||
see the javadoc for Spring's {api-spring-framework}/context/event/ApplicationEventMulticaster.html[`ApplicationEventMulticaster`] interface
|
||||
and {api-spring-framework}/context/event/SimpleApplicationEventMulticaster.html[`SimpleApplicationEventMulticaster`] implementation
|
||||
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.
|
||||
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
|
||||
within the same application context. However, for more sophisticated enterprise
|
||||
integration needs, the separately maintained
|
||||
{spring-site-projects}/spring-integration/[Spring Integration] project provides
|
||||
https://projects.spring.io/spring-integration/[Spring Integration] project provides
|
||||
complete support for building lightweight,
|
||||
https://www.enterpriseintegrationpatterns.com[pattern-oriented], event-driven
|
||||
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
|
||||
caller. See
|
||||
{spring-framework-api}/aop/interceptor/AsyncUncaughtExceptionHandler.html[`AsyncUncaughtExceptionHandler`]
|
||||
{api-spring-framework}/aop/interceptor/AsyncUncaughtExceptionHandler.html[`AsyncUncaughtExceptionHandler`]
|
||||
for more details.
|
||||
* 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
|
||||
{spring-framework-api}/context/ApplicationEventPublisher.html[`ApplicationEventPublisher`]
|
||||
{api-spring-framework}/context/ApplicationEventPublisher.html[`ApplicationEventPublisher`]
|
||||
to publish the event manually.
|
||||
* 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]
|
||||
@@ -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.
|
||||
|
||||
See the javadoc of the
|
||||
{spring-framework-api}/jca/context/SpringContextResourceAdapter.html[`SpringContextResourceAdapter`]
|
||||
{api-spring-framework}/jca/context/SpringContextResourceAdapter.html[`SpringContextResourceAdapter`]
|
||||
class for the configuration details involved in RAR deployment.
|
||||
|
||||
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).
|
||||
. Add all required library JARs into the root of the RAR archive.
|
||||
. Add a
|
||||
`META-INF/ra.xml` deployment descriptor (as shown in the {spring-framework-api}/jca/context/SpringContextResourceAdapter.html[javadoc for `SpringContextResourceAdapter`])
|
||||
`META-INF/ra.xml` deployment descriptor (as shown in the {api-spring-framework}/jca/context/SpringContextResourceAdapter.html[javadoc for `SpringContextResourceAdapter`])
|
||||
and the corresponding Spring XML bean definition file(s) (typically
|
||||
`META-INF/applicationContext.xml`).
|
||||
. 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
|
||||
necessary for JPA class transformation.
|
||||
Consult the
|
||||
{spring-framework-api}/orm/jpa/LocalContainerEntityManagerFactoryBean.html[`LocalContainerEntityManagerFactoryBean`]
|
||||
{api-spring-framework}/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].
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -99,7 +99,7 @@ container, lets you handle this use case cleanly.
|
||||
|
||||
****
|
||||
You can read more about the motivation for Method Injection in
|
||||
{spring-site-blog}/2004/08/06/method-injection/[this blog entry].
|
||||
https://spring.io/blog/2004/08/06/method-injection/[this blog entry].
|
||||
****
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ XML configuration:
|
||||
|
||||
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
|
||||
IDEA] or the {spring-site-tools}[Spring Tools for Eclipse])
|
||||
IDEA] or the https://spring.io/tools[Spring Tools for Eclipse])
|
||||
that supports automatic property completion when you create bean definitions. Such IDE
|
||||
assistance is highly recommended.
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[[beans-environment]]
|
||||
= Environment Abstraction
|
||||
|
||||
The {spring-framework-api}/core/env/Environment.html[`Environment`] interface
|
||||
The {api-spring-framework}/core/env/Environment.html[`Environment`] interface
|
||||
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]
|
||||
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]]
|
||||
=== Using `@Profile`
|
||||
|
||||
The {spring-framework-api}/context/annotation/Profile.html[`@Profile`]
|
||||
The {api-spring-framework}/context/annotation/Profile.html[`@Profile`]
|
||||
annotation lets you indicate that a component is eligible for registration
|
||||
when one or more specified profiles are active. Using our preceding example, we
|
||||
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
|
||||
defined for the current environment. To answer this question, the `Environment` object performs
|
||||
a search over a set of {spring-framework-api}/core/env/PropertySource.html[`PropertySource`]
|
||||
a search over a set of {api-spring-framework}/core/env/PropertySource.html[`PropertySource`]
|
||||
objects. A `PropertySource` is a simple abstraction over any source of key-value pairs, and
|
||||
Spring's {spring-framework-api}/core/env/StandardEnvironment.html[`StandardEnvironment`]
|
||||
Spring's {api-spring-framework}/core/env/StandardEnvironment.html[`StandardEnvironment`]
|
||||
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.getenv()`).
|
||||
|
||||
NOTE: These default property sources are present for `StandardEnvironment`, for use in standalone
|
||||
applications. {spring-framework-api}/web/context/support/StandardServletEnvironment.html[`StandardServletEnvironment`]
|
||||
applications. {api-spring-framework}/web/context/support/StandardServletEnvironment.html[`StandardServletEnvironment`]
|
||||
is populated with additional default property sources including servlet config, servlet
|
||||
context parameters, and a {spring-framework-api}/jndi/JndiPropertySource.html[`JndiPropertySource`]
|
||||
context parameters, and a {api-spring-framework}/jndi/JndiPropertySource.html[`JndiPropertySource`]
|
||||
if JNDI is available.
|
||||
|
||||
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
|
||||
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
|
||||
{spring-framework-api}/core/env/MutablePropertySources.html[`MutablePropertySources`]
|
||||
{api-spring-framework}/core/env/MutablePropertySources.html[`MutablePropertySources`]
|
||||
API exposes a number of methods that allow for precise manipulation of the set of
|
||||
property sources.
|
||||
|
||||
@@ -672,7 +672,7 @@ property sources.
|
||||
[[beans-using-propertysource]]
|
||||
== Using `@PropertySource`
|
||||
|
||||
The {spring-framework-api}/context/annotation/PropertySource.html[`@PropertySource`]
|
||||
The {api-spring-framework}/context/annotation/PropertySource.html[`@PropertySource`]
|
||||
annotation provides a convenient and declarative mechanism for adding a `PropertySource`
|
||||
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`
|
||||
interface. If you write your own `BeanPostProcessor`, you should consider implementing
|
||||
the `Ordered` interface, too. For further details, see the javadoc of the
|
||||
{spring-framework-api}/beans/factory/config/BeanPostProcessor.html[`BeanPostProcessor`]
|
||||
and {spring-framework-api}/core/Ordered.html[`Ordered`] interfaces. See also the note on
|
||||
{api-spring-framework}/beans/factory/config/BeanPostProcessor.html[`BeanPostProcessor`]
|
||||
and {api-spring-framework}/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].
|
||||
|
||||
[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
|
||||
`Ordered` interface. If you write your own `BeanFactoryPostProcessor`, you should
|
||||
consider implementing the `Ordered` interface, too. See the javadoc of the
|
||||
{spring-framework-api}/beans/factory/config/BeanFactoryPostProcessor.html[`BeanFactoryPostProcessor`]
|
||||
and {spring-framework-api}/core/Ordered.html[`Ordered`] interfaces for more details.
|
||||
{api-spring-framework}/beans/factory/config/BeanFactoryPostProcessor.html[`BeanFactoryPostProcessor`]
|
||||
and {api-spring-framework}/core/Ordered.html[`Ordered`] interfaces for more details.
|
||||
|
||||
[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,
|
||||
see the documentation for
|
||||
{spring-framework-api}/context/support/SimpleThreadScope.html[`SimpleThreadScope`].
|
||||
{api-spring-framework}/context/support/SimpleThreadScope.html[`SimpleThreadScope`].
|
||||
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].
|
||||
|
||||
@@ -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
|
||||
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
|
||||
{spring-framework-api}/beans/factory/config/Scope.html[`Scope`] javadoc,
|
||||
{api-spring-framework}/beans/factory/config/Scope.html[`Scope`] javadoc,
|
||||
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
|
||||
@@ -629,7 +629,7 @@ Kotlin::
|
||||
----
|
||||
======
|
||||
|
||||
See the {spring-framework-api}/beans/factory/config/Scope.html#registerDestructionCallback[javadoc]
|
||||
See the {api-spring-framework}/beans/factory/config/Scope.html#registerDestructionCallback[javadoc]
|
||||
or a Spring scope implementation for more information on destruction callbacks.
|
||||
|
||||
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
|
||||
for Spring Framework's IoC container. The
|
||||
{spring-framework-api}/beans/factory/BeanFactory.html[`BeanFactory`]
|
||||
{api-spring-framework}/beans/factory/BeanFactory.html[`BeanFactory`]
|
||||
interface provides an advanced configuration mechanism capable of managing any type of
|
||||
object.
|
||||
{spring-framework-api}/context/ApplicationContext.html[`ApplicationContext`]
|
||||
{api-spring-framework}/context/ApplicationContext.html[`ApplicationContext`]
|
||||
is a sub-interface of `BeanFactory`. It adds:
|
||||
|
||||
* 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.
|
||||
|
||||
To add a description to a `@Bean`, you can use the
|
||||
{spring-framework-api}/context/annotation/Description.html[`@Description`]
|
||||
{api-spring-framework}/context/annotation/Description.html[`@Description`]
|
||||
annotation, as the following example shows:
|
||||
|
||||
[tabs]
|
||||
|
||||
+4
-4
@@ -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
|
||||
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
|
||||
{spring-framework-api}/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.html[`AutowiredAnnotationBeanPostProcessor`].
|
||||
{api-spring-framework}/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.html[`AutowiredAnnotationBeanPostProcessor`].
|
||||
====
|
||||
|
||||
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
|
||||
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
|
||||
{spring-site-tools}[Spring Tools for Eclipse] provides tooling that
|
||||
https://spring.io/tools[Spring Tools for Eclipse] provides tooling that
|
||||
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
|
||||
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).
|
||||
|
||||
The `@Profile` annotation is actually implemented by using a much more flexible annotation
|
||||
called {spring-framework-api}/context/annotation/Conditional.html[`@Conditional`].
|
||||
called {api-spring-framework}/context/annotation/Conditional.html[`@Conditional`].
|
||||
The `@Conditional` annotation indicates specific
|
||||
`org.springframework.context.annotation.Condition` implementations that should be
|
||||
consulted before a `@Bean` is registered.
|
||||
@@ -570,7 +570,7 @@ Kotlin::
|
||||
----
|
||||
======
|
||||
|
||||
See the {spring-framework-api}/context/annotation/Conditional.html[`@Conditional`]
|
||||
See the {api-spring-framework}/context/annotation/Conditional.html[`@Conditional`]
|
||||
javadoc for more detail.
|
||||
|
||||
|
||||
|
||||
@@ -278,7 +278,7 @@ init-param):
|
||||
|
||||
NOTE: For programmatic use cases, a `GenericWebApplicationContext` can be used as an
|
||||
alternative to `AnnotationConfigWebApplicationContext`. See the
|
||||
{spring-framework-api}/web/context/support/GenericWebApplicationContext.html[`GenericWebApplicationContext`]
|
||||
{api-spring-framework}/web/context/support/GenericWebApplicationContext.html[`GenericWebApplicationContext`]
|
||||
javadoc for details.
|
||||
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ alternate between read and write.
|
||||
== `PooledDataBuffer`
|
||||
|
||||
As explained in the Javadoc for
|
||||
{java-api}/java.base/java/nio/ByteBuffer.html[ByteBuffer],
|
||||
https://docs.oracle.com/javase/8/docs/api/java/nio/ByteBuffer.html[ByteBuffer],
|
||||
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
|
||||
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
|
||||
the products in the Spring portfolio. Its language features are driven by the
|
||||
requirements of the projects in the Spring portfolio, including tooling requirements
|
||||
for code completion support within the {spring-site-tools}[Spring Tools for Eclipse].
|
||||
for code completion support within the https://spring.io/tools[Spring Tools for Eclipse].
|
||||
That said, SpEL is based on a technology-agnostic API that lets other expression language
|
||||
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
|
||||
declare nullability of APIs and fields:
|
||||
|
||||
* {spring-framework-api}/lang/Nullable.html[`@Nullable`]: Annotation to indicate that a
|
||||
* {api-spring-framework}/lang/Nullable.html[`@Nullable`]: Annotation to indicate that a
|
||||
specific parameter, return value, or field can be `null`.
|
||||
* {spring-framework-api}/lang/NonNull.html[`@NonNull`]: Annotation to indicate that a specific
|
||||
* {api-spring-framework}/lang/NonNull.html[`@NonNull`]: Annotation to indicate that a specific
|
||||
parameter, return value, or field cannot be `null` (not needed on parameters, return values,
|
||||
and fields where `@NonNullApi` and `@NonNullFields` apply, respectively).
|
||||
* {spring-framework-api}/lang/NonNullApi.html[`@NonNullApi`]: Annotation at the package level
|
||||
* {api-spring-framework}/lang/NonNullApi.html[`@NonNullApi`]: Annotation at the package level
|
||||
that declares non-null as the default semantics for parameters and return values.
|
||||
* {spring-framework-api}/lang/NonNullFields.html[`@NonNullFields`]: Annotation at the package
|
||||
* {api-spring-framework}/lang/NonNullFields.html[`@NonNullFields`]: Annotation at the package
|
||||
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
|
||||
@@ -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.
|
||||
|
||||
They are also used to make Spring APIs null-safe in Kotlin projects, since Kotlin natively
|
||||
supports {kotlin-docs}/null-safety.html[null-safety]. More details
|
||||
supports https://kotlinlang.org/docs/null-safety.html[null-safety]. More details
|
||||
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
|
||||
|
||||
Spring annotations are meta-annotated with {JSR}305[JSR 305]
|
||||
Spring annotations are meta-annotated with https://jcp.org/en/jsr/detail?id=305[JSR 305]
|
||||
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
|
||||
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
|
||||
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
|
||||
{spring-framework-api}/core/io/Resource.html[`Resource`] javadoc for further details.
|
||||
{api-spring-framework}/core/io/Resource.html[`Resource`] javadoc for further details.
|
||||
|
||||
|
||||
[source,java,indent=0,subs="verbatim,quotes"]
|
||||
@@ -104,7 +104,7 @@ resource (if the underlying implementation is compatible and supports that
|
||||
functionality).
|
||||
|
||||
Some implementations of the `Resource` interface also implement the extended
|
||||
{spring-framework-api}/core/io/WritableResource.html[`WritableResource`] interface
|
||||
{api-spring-framework}/core/io/WritableResource.html[`WritableResource`] interface
|
||||
for a resource that supports writing to it.
|
||||
|
||||
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
|
||||
"All Known Implementing Classes" section of the
|
||||
{spring-framework-api}/core/io/Resource.html[`Resource`] javadoc.
|
||||
{api-spring-framework}/core/io/Resource.html[`Resource`] javadoc.
|
||||
|
||||
|
||||
|
||||
@@ -763,7 +763,7 @@ Kotlin::
|
||||
----
|
||||
======
|
||||
|
||||
See the {spring-framework-api}/context/support/ClassPathXmlApplicationContext.html[`ClassPathXmlApplicationContext`]
|
||||
See the {api-spring-framework}/context/support/ClassPathXmlApplicationContext.html[`ClassPathXmlApplicationContext`]
|
||||
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
|
||||
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
|
||||
{stackoverflow-questions}/19394570/java-jre-7u45-breaks-classloader-getresources).
|
||||
https://stackoverflow.com/questions/19394570/java-jre-7u45-breaks-classloader-getresources).
|
||||
|
||||
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,
|
||||
|
||||
@@ -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
|
||||
bridges, and let the framework auto-adapt to your choice. For further information see the
|
||||
{spring-boot-docs}/features.html#features.logging[Spring
|
||||
https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-logging[Spring
|
||||
Boot Logging Reference Documentation].
|
||||
|
||||
[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
|
||||
have a setter method `setBingoMadness(..)` and a getter method `getBingoMadness()`. For
|
||||
more information about JavaBeans and the specification, see
|
||||
{java-api}/java.desktop/java/beans/package-summary.html[javabeans].
|
||||
https://docs.oracle.com/javase/8/docs/api/java/beans/package-summary.html[javabeans].
|
||||
|
||||
One quite important class in the beans package is the `BeanWrapper` interface and its
|
||||
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,
|
||||
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
|
||||
`PropertyEditor`, see {java-api}/java.desktop/java/beans/package-summary.html[the javadoc of the `java.beans` package from Oracle].
|
||||
`PropertyEditor`, see https://docs.oracle.com/javase/8/docs/api/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:
|
||||
|
||||
@@ -355,7 +355,7 @@ com
|
||||
|
||||
Note that you can also use the standard `BeanInfo` JavaBeans mechanism here as well
|
||||
(described to some extent
|
||||
{java-tutorial}/javabeans/advanced/customization.html[here]). The
|
||||
https://docs.oracle.com/javase/tutorial/javabeans/advanced/customization.html[here]). The
|
||||
following example uses the `BeanInfo` mechanism to explicitly register one or more
|
||||
`PropertyEditor` instances with the properties of an associated class:
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
= Java Bean Validation
|
||||
|
||||
The Spring Framework provides support for the
|
||||
{bean-validation-site}[Java Bean Validation] API.
|
||||
https://beanvalidation.org/[Java Bean Validation] API.
|
||||
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ Kotlin::
|
||||
======
|
||||
|
||||
A Bean Validation validator then validates instances of this class based on the declared
|
||||
constraints. See {bean-validation-site}[Bean Validation] for general information about
|
||||
constraints. See https://beanvalidation.org/[Bean Validation] for general information about
|
||||
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
|
||||
bean, keep reading.
|
||||
@@ -317,7 +317,7 @@ XML::
|
||||
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
|
||||
groups to use. See
|
||||
{spring-framework-api}/validation/beanvalidation/MethodValidationPostProcessor.html[`MethodValidationPostProcessor`]
|
||||
{api-spring-framework}/validation/beanvalidation/MethodValidationPostProcessor.html[`MethodValidationPostProcessor`]
|
||||
for setup details with the Hibernate Validator and Bean Validation providers.
|
||||
|
||||
[TIP]
|
||||
@@ -472,7 +472,7 @@ Max.degrees=You cannot provide more than {1} {0}
|
||||
The default `LocalValidatorFactoryBean` configuration suffices for most
|
||||
cases. There are a number of configuration options for various Bean Validation
|
||||
constructs, from message interpolation to traversal resolution. See the
|
||||
{spring-framework-api}/validation/beanvalidation/LocalValidatorFactoryBean.html[`LocalValidatorFactoryBean`]
|
||||
{api-spring-framework}/validation/beanvalidation/LocalValidatorFactoryBean.html[`LocalValidatorFactoryBean`]
|
||||
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
|
||||
in the javadoc of
|
||||
{spring-framework-api}/validation/MessageCodesResolver.html[`MessageCodesResolver`] and
|
||||
{spring-framework-api}/validation/DefaultMessageCodesResolver.html[`DefaultMessageCodesResolver`],
|
||||
{api-spring-framework}/validation/MessageCodesResolver.html[`MessageCodesResolver`] and
|
||||
{api-spring-framework}/validation/DefaultMessageCodesResolver.html[`DefaultMessageCodesResolver`],
|
||||
respectively.
|
||||
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ Kotlin::
|
||||
======
|
||||
|
||||
The Spring team welcomes community-driven `Formatter` contributions. See
|
||||
{spring-framework-issues}[GitHub Issues] to contribute.
|
||||
https://github.com/spring-projects/spring-framework/issues[GitHub Issues] to contribute.
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ Kotlin::
|
||||
|
||||
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
|
||||
{spring-framework-api}/validation/ValidationUtils.html[`ValidationUtils`] javadoc
|
||||
{api-spring-framework}/validation/ValidationUtils.html[`ValidationUtils`] javadoc
|
||||
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
|
||||
@@ -193,7 +193,7 @@ Kotlin::
|
||||
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
|
||||
you can also inspect the `Errors` object yourself. More information about the
|
||||
methods it offers can be found in the {spring-framework-api}/validation/Errors.html[javadoc].
|
||||
methods it offers can be found in the {api-spring-framework}/validation/Errors.html[javadoc].
|
||||
|
||||
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
|
||||
|
||||
@@ -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
|
||||
`JdbcTemplate` or `DataSourceUtils`.
|
||||
|
||||
See the {spring-framework-api}/jdbc/datasource/TransactionAwareDataSourceProxy.html[`TransactionAwareDataSourceProxy`]
|
||||
See the {api-spring-framework}/jdbc/datasource/TransactionAwareDataSourceProxy.html[`TransactionAwareDataSourceProxy`]
|
||||
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
|
||||
are not an exhaustive list of all of the functionality exposed by the `JdbcTemplate`.
|
||||
See the attendant {spring-framework-api}/jdbc/core/JdbcTemplate.html[javadoc] for that.
|
||||
See the attendant {api-spring-framework}/jdbc/core/JdbcTemplate.html[javadoc] for that.
|
||||
|
||||
[[jdbc-JdbcTemplate-examples-query]]
|
||||
=== Querying (`SELECT`)
|
||||
|
||||
@@ -83,7 +83,7 @@ Kotlin::
|
||||
----
|
||||
======
|
||||
|
||||
See the {spring-framework-api}/jdbc/datasource/embedded/EmbeddedDatabaseBuilder.html[javadoc for `EmbeddedDatabaseBuilder`]
|
||||
See the {api-spring-framework}/jdbc/datasource/embedded/EmbeddedDatabaseBuilder.html[javadoc for `EmbeddedDatabaseBuilder`]
|
||||
for further details on all supported options.
|
||||
|
||||
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.
|
||||
|
||||
We encourage you to contribute extensions to the Spring community at
|
||||
{spring-framework-issues}[GitHub Issues].
|
||||
https://github.com/spring-projects/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
|
||||
technologies such as MongoDB, you might want to check out the
|
||||
{spring-site-projects}/spring-data/[Spring Data] suite of projects. If you are
|
||||
a JPA user, the {spring-site-guides}/gs/accessing-data-jpa/[Getting Started Accessing
|
||||
https://projects.spring.io/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
|
||||
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
|
||||
environment is a web container or application server. Hooking `ClassTransformers`
|
||||
through an
|
||||
{java-api}/java.instrument/java/lang/instrument/package-summary.html[agent]
|
||||
https://docs.oracle.com/javase/6/docs/api/java/lang/instrument/package-summary.html[agent]
|
||||
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
|
||||
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
|
||||
Spring-driven transaction management (that is, for use with `JpaTransactionManager`).
|
||||
|
||||
See the {spring-framework-api}/orm/jpa/JpaDialect.html[`JpaDialect`] and
|
||||
{spring-framework-api}/orm/jpa/JpaVendorAdapter.html[`JpaVendorAdapter`] javadoc for
|
||||
See the {api-spring-framework}/orm/jpa/JpaDialect.html[`JpaDialect`] and
|
||||
{api-spring-framework}/orm/jpa/JpaVendorAdapter.html[`JpaVendorAdapter`] javadoc for
|
||||
more details of its operations and how they are used within Spring's JPA support.
|
||||
|
||||
|
||||
|
||||
@@ -36,8 +36,8 @@ simpler.
|
||||
[[oxm-consistent-interfaces]]
|
||||
=== Consistent Interfaces
|
||||
|
||||
Spring's O-X mapping operates through two global interfaces: {spring-framework-api}/oxm/Marshaller.html[`Marshaller`] and
|
||||
{spring-framework-api}/oxm/Unmarshaller.html[`Unmarshaller`]. These abstractions let you switch O-X mapping frameworks
|
||||
Spring's O-X mapping operates through two global interfaces: {api-spring-framework}/oxm/Marshaller.html[`Marshaller`] and
|
||||
{api-spring-framework}/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
|
||||
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
|
||||
@@ -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.
|
||||
|
||||
Additionally, you can register
|
||||
{spring-framework-api}/oxm/xstream/XStreamMarshaller.html#setConverters(com.thoughtworks.xstream.converters.ConverterMatcher...)[custom
|
||||
{api-spring-framework}/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
|
||||
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
|
||||
|
||||
@@ -95,7 +95,7 @@ parameter to database bind marker translation.
|
||||
run.
|
||||
* `….namedParameters(false)`: Disable named parameter expansion. Enabled by default.
|
||||
|
||||
TIP: Dialects are resolved by {spring-framework-api}/r2dbc/core/binding/BindMarkersFactoryResolver.html[`BindMarkersFactoryResolver`]
|
||||
TIP: Dialects are resolved by {api-spring-framework}/r2dbc/core/binding/BindMarkersFactoryResolver.html[`BindMarkersFactoryResolver`]
|
||||
from a `ConnectionFactory`, typically by inspecting `ConnectionFactoryMetadata`.
|
||||
+
|
||||
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
|
||||
are not an exhaustive list of all of the functionality exposed by the `DatabaseClient`.
|
||||
See the attendant {spring-framework-api}/r2dbc/core/DatabaseClient.html[javadoc] for that.
|
||||
See the attendant {api-spring-framework}/r2dbc/core/DatabaseClient.html[javadoc] for that.
|
||||
|
||||
[[r2dbc-DatabaseClient-examples-statement]]
|
||||
==== 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`
|
||||
for resource management.
|
||||
|
||||
See the {spring-framework-api}/r2dbc/connection/TransactionAwareConnectionFactoryProxy.html[`TransactionAwareConnectionFactoryProxy`]
|
||||
See the {api-spring-framework}/r2dbc/connection/TransactionAwareConnectionFactoryProxy.html[`TransactionAwareConnectionFactoryProxy`]
|
||||
javadoc for more details.
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -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
|
||||
`TransactionManager` allows for enhanced transaction semantics -- in particular,
|
||||
supporting transaction suspension. See the
|
||||
{spring-framework-api}/transaction/jta/JtaTransactionManager.html[`JtaTransactionManager`]
|
||||
{api-spring-framework}/transaction/jta/JtaTransactionManager.html[`JtaTransactionManager`]
|
||||
javadoc for details.
|
||||
|
||||
Spring's `JtaTransactionManager` is the standard choice to run on Jakarta EE application
|
||||
|
||||
+2
-2
@@ -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,
|
||||
you can make the bean instance transactional through an `@EnableTransactionManagement`
|
||||
annotation in a `@Configuration` class. See the
|
||||
{spring-framework-api}/transaction/annotation/EnableTransactionManagement.html[javadoc]
|
||||
{api-spring-framework}/transaction/annotation/EnableTransactionManagement.html[javadoc]
|
||||
for full details.
|
||||
|
||||
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
|
||||
|
||||
| `transaction-manager`
|
||||
| N/A (see {spring-framework-api}/transaction/annotation/TransactionManagementConfigurer.html[`TransactionManagementConfigurer`] javadoc)
|
||||
| N/A (see {api-spring-framework}/transaction/annotation/TransactionManagementConfigurer.html[`TransactionManagementConfigurer`] javadoc)
|
||||
| `transactionManager`
|
||||
| Name of the transaction manager to use. Required only if the name of the transaction
|
||||
manager is not `transactionManager`, as in the preceding example.
|
||||
|
||||
@@ -57,7 +57,8 @@ transaction semantics given by the class annotation (if present). You can annota
|
||||
regardless of visibility.
|
||||
|
||||
To weave your applications with the `AnnotationTransactionAspect`, you must either build
|
||||
your application with AspectJ (see the {aspectj-docs-devguide}/index.html[AspectJ Development
|
||||
your application with AspectJ (see the
|
||||
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]
|
||||
for a discussion of load-time weaving with AspectJ.
|
||||
|
||||
|
||||
+1
-1
@@ -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
|
||||
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
|
||||
transactions. See Spring's {spring-framework-api}/jdbc/datasource/DataSourceTransactionManager.html[`DataSourceTransactionManager`].
|
||||
transactions. See Spring's {api-spring-framework}/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
|
||||
context needs to be included in the published event instance as the event source.
|
||||
See the
|
||||
{spring-framework-api}/transaction/reactive/TransactionalEventPublisher.html[`TransactionalEventPublisher`]
|
||||
{api-spring-framework}/transaction/reactive/TransactionalEventPublisher.html[`TransactionalEventPublisher`]
|
||||
javadoc for details.
|
||||
====
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ xref:integration.adoc[Integration] :: REST Clients, JMS, JCA, JMX,
|
||||
Email, Tasks, Scheduling, Caching, Observability, JVM Checkpoint Restore.
|
||||
xref:languages.adoc[Languages] :: Kotlin, Groovy, Dynamic Languages.
|
||||
xref:testing/appendix.adoc[Appendix] :: Spring properties.
|
||||
{spring-framework-wiki}[Wiki] :: What's New,
|
||||
https://github.com/spring-projects/spring-framework/wiki[Wiki] :: What's New,
|
||||
Upgrade Notes, Supported Versions, additional cross-version information.
|
||||
|
||||
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
|
||||
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
|
||||
unexpected key collisions (see {spring-framework-issues}/14870[spring-framework#14870]
|
||||
unexpected key collisions (see https://jira.spring.io/browse/SPR-10237[SPR-10237]
|
||||
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
|
||||
@@ -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
|
||||
required to implement `CachingConfigurer`, see the
|
||||
{spring-framework-api}/cache/annotation/CachingConfigurer.html[javadoc].
|
||||
{api-spring-framework}/cache/annotation/CachingConfigurer.html[javadoc].
|
||||
|
||||
[[cache-annotation-driven-settings]]
|
||||
.Cache annotation settings
|
||||
@@ -575,7 +575,7 @@ required to implement `CachingConfigurer`, see the
|
||||
| XML Attribute | Annotation Attribute | Default | Description
|
||||
|
||||
| `cache-manager`
|
||||
| N/A (see the {spring-framework-api}/cache/annotation/CachingConfigurer.html[`CachingConfigurer`] javadoc)
|
||||
| N/A (see the {api-spring-framework}/cache/annotation/CachingConfigurer.html[`CachingConfigurer`] javadoc)
|
||||
| `cacheManager`
|
||||
| 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
|
||||
@@ -583,19 +583,19 @@ required to implement `CachingConfigurer`, see the
|
||||
attribute.
|
||||
|
||||
| `cache-resolver`
|
||||
| N/A (see the {spring-framework-api}/cache/annotation/CachingConfigurer.html[`CachingConfigurer`] javadoc)
|
||||
| N/A (see the {api-spring-framework}/cache/annotation/CachingConfigurer.html[`CachingConfigurer`] javadoc)
|
||||
| A `SimpleCacheResolver` using the configured `cacheManager`.
|
||||
| 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
|
||||
the 'cache-manager' attribute.
|
||||
|
||||
| `key-generator`
|
||||
| N/A (see the {spring-framework-api}/cache/annotation/CachingConfigurer.html[`CachingConfigurer`] javadoc)
|
||||
| N/A (see the {api-spring-framework}/cache/annotation/CachingConfigurer.html[`CachingConfigurer`] javadoc)
|
||||
| `SimpleKeyGenerator`
|
||||
| Name of the custom key generator to use.
|
||||
|
||||
| `error-handler`
|
||||
| N/A (see the {spring-framework-api}/cache/annotation/CachingConfigurer.html[`CachingConfigurer`] javadoc)
|
||||
| N/A (see the {api-spring-framework}/cache/annotation/CachingConfigurer.html[`CachingConfigurer`] javadoc)
|
||||
| `SimpleCacheErrorHandler`
|
||||
| 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.
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
[[checkpoint-restore]]
|
||||
= JVM Checkpoint Restore
|
||||
|
||||
The Spring Framework integrates with checkpoint/restore as implemented by https://github.com/CRaC/docs[Project CRaC] in order to allow implementing systems capable of reducing the startup and warmup times of Spring-based Java applications with the JVM.
|
||||
The Spring Framework integrates with checkpoint/restore as implemented by https://github.com/CRaC/docs[Project CRaC] in order to allow implementing systems capable to reduce the startup and warmup times of Spring-based Java applications with the JVM.
|
||||
|
||||
Using this feature requires:
|
||||
|
||||
* A checkpoint/restore enabled JVM (Linux only for now).
|
||||
* The presence of the https://github.com/CRaC/org.crac[`org.crac:crac`] library (version `1.4.0` and above are supported) in the classpath.
|
||||
* Specifying the required `java` command-line parameters like `-XX:CRaCCheckpointTo=PATH` or `-XX:CRaCRestoreFrom=PATH`.
|
||||
* The presence in the classpath of the https://github.com/CRaC/org.crac[`org.crac:crac`] library (version `1.4.0` and above are supported).
|
||||
* Specifying the required `java` command line parameters like `-XX:CRaCCheckpointTo=PATH` or `-XX:CRaCRestoreFrom=PATH`.
|
||||
|
||||
WARNING: The files generated in the path specified by `-XX:CRaCCheckpointTo=PATH` when a checkpoint is requested contain a representation of the memory of the running JVM, which may contain secrets and other sensitive data. Using this feature should be done with the assumption that any value "seen" by the JVM, such as configuration properties coming from the environment, will be stored in those CRaC files. As a consequence, the security implications of where and how those files are generated, stored, and accessed should be carefully assessed.
|
||||
WARNING: The files generated in the path specified by `-XX:CRaCCheckpointTo=PATH` when a checkpoint is requested contain a representation of the memory of the running JVM, which may contain secrets and other sensitive data. Using this feature should be done with the assumption that any value "seen" by the JVM, such as configuration properties coming from the environment, will be stored in those CRaC files. As a consequence, the security implications of where and how those files are generated, stored and accessed should be carefully assessed.
|
||||
|
||||
Conceptually, checkpoint and restore align with the xref:core/beans/factory-nature.adoc#beans-factory-lifecycle-processor[Spring `Lifecycle` contract] for individual beans.
|
||||
Conceptually, checkpoint and restore match with xref:core/beans/factory-nature.adoc#beans-factory-lifecycle-processor[Spring `Lifecycle` contract] for individual beans.
|
||||
|
||||
== On-demand checkpoint/restore of a running application
|
||||
== On demand checkpoint/restore of a running application
|
||||
|
||||
A checkpoint can be created on demand, for example using a command like `jcmd application.jar JDK.checkpoint`. Before the creation of the checkpoint, Spring Framework
|
||||
stops all the running beans, giving them a chance to close resources if needed by implementing `Lifecycle.stop`. After restore, the same beans are restarted, with `Lifecycle.start` allowing beans to reopen resources when relevant. For libraries that do not depend on Spring, custom checkpoint/restore integration can be provided by implementing `org.crac.Resource` and registering the related instance.
|
||||
stops all the running beans, giving them a chance to close resources if needed by implementing `Lifecycle.stop`. After restore, the same beans are restarted, with `Lifecycle.start` allowing to reopen resources when relevant. For libraries not depending on Spring, checkpoint/restore custom integration can be provided by implementing `org.crac.Resource` and registering the related instance.
|
||||
|
||||
WARNING: Leveraging checkpoint/restore of a running application typically requires additional lifecycle management to gracefully stop and start using resources like files or sockets and stop active threads.
|
||||
|
||||
@@ -24,11 +24,8 @@ NOTE: If the checkpoint is created on a warmed-up JVM, the restored JVM will be
|
||||
|
||||
== Automatic checkpoint/restore at startup
|
||||
|
||||
When the `-Dspring.context.checkpoint=onRefresh` JVM system property is set, a checkpoint is created automatically at
|
||||
startup during the `LifecycleProcessor.onRefresh` phase. After this phase has completed, all non-lazy initialized singletons have been instantiated, and
|
||||
`InitializingBean#afterPropertiesSet` callbacks have been invoked; but the lifecycle has not started, and the
|
||||
`ContextRefreshedEvent` has not yet been published.
|
||||
When the `-Dspring.context.checkpoint=onRefresh` Java system property is set, a checkpoint is created automatically during the startup at `LifecycleProcessor.onRefresh` level. At this phase, all non-lazy initialized singletons are instantiated, `InitializingBean.afterPropertiesSet` callbacks have been invoked, but not `Lifecycle.start` ones and `ContextRefreshedEvent` has not yet been published.
|
||||
|
||||
WARNING: As mentioned above, and especially in use cases where the CRaC files are shipped as part of a deployable artifact (a container image for example), operate with the assumption that any sensitive data "seen" by the JVM ends up in the CRaC files, and assess carefully the related security implications.
|
||||
|
||||
NOTE: Automatic checkpoint/restore is a way to "fast-forward" the startup of the application to a phase where the application context is about to start, but it does not allow to have a fully warmed-up JVM.
|
||||
NOTE: Here checkpoint/restore is a way to "fast-forward" the startup of the application to a phase where the application context is about to start, but does not allow to have a fully warmed-up JVM.
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
[[class-data-sharing]]
|
||||
= Class Data Sharing
|
||||
|
||||
Class Data Sharing (CDS) is a https://docs.oracle.com/en/java/javase/17/vm/class-data-sharing.html[JVM feature]
|
||||
that can help reduce the startup time and memory footprint of Java applications.
|
||||
|
||||
To use this feature, a CDS archive should be created for the particular classpath of the
|
||||
application. The Spring Framework provides a hook-point to ease the creation of the
|
||||
archive. Once the archive is available, users should opt in to use it via a JVM flag.
|
||||
|
||||
== Creating the CDS Archive
|
||||
|
||||
A CDS archive for an application can be created when the application exits. The Spring
|
||||
Framework provides a mode of operation where the process can exit automatically once the
|
||||
`ApplicationContext` has refreshed. In this mode, all non-lazy initialized singletons
|
||||
have been instantiated, and `InitializingBean#afterPropertiesSet` callbacks have been
|
||||
invoked; but the lifecycle has not started, and the `ContextRefreshedEvent` has not yet
|
||||
been published.
|
||||
|
||||
To create the archive, two additional JVM flags must be specified:
|
||||
|
||||
* `-XX:ArchiveClassesAtExit=app-cds.jsa`: creates the CDS archive on exit
|
||||
* `-Dspring.context.exit=onRefresh`: starts and then immediately exits your Spring
|
||||
application as described above
|
||||
|
||||
To create a CDS archive, your JDK must have a base image. If you add the flags above to
|
||||
your startup script, you may get a warning that looks like this:
|
||||
|
||||
[source,shell,indent=0,subs="verbatim"]
|
||||
----
|
||||
-XX:ArchiveClassesAtExit is unsupported when base CDS archive is not loaded. Run with -Xlog:cds for more info.
|
||||
----
|
||||
|
||||
The base CDS archive can be created by issuing the following command:
|
||||
|
||||
[source,shell,indent=0,subs="verbatim"]
|
||||
----
|
||||
$ java -Xshare:dump
|
||||
----
|
||||
|
||||
== Using the Archive
|
||||
|
||||
Once the archive is available, add `-XX:SharedArchiveFile=app-cds.jsa` to your startup
|
||||
script to use it, assuming a `app-cds.jsa` file in the working directory.
|
||||
|
||||
To figure out how effective the cache is, you can enable class loading logs by adding
|
||||
an extra attribute: `-Xlog:class+load:file=cds.log`. This creates a `cds.log` with every
|
||||
attempt to load a class and its source. Classes that are loaded from the cache should have
|
||||
a "shared objects file" source, as shown in the following example:
|
||||
|
||||
[source,shell,indent=0,subs="verbatim"]
|
||||
----
|
||||
[0.064s][info][class,load] org.springframework.core.env.EnvironmentCapable source: shared objects file (top)
|
||||
[0.064s][info][class,load] org.springframework.beans.factory.BeanFactory source: shared objects file (top)
|
||||
[0.064s][info][class,load] org.springframework.beans.factory.ListableBeanFactory source: shared objects file (top)
|
||||
[0.064s][info][class,load] org.springframework.beans.factory.HierarchicalBeanFactory source: shared objects file (top)
|
||||
[0.065s][info][class,load] org.springframework.context.MessageSource source: shared objects file (top)
|
||||
----
|
||||
|
||||
TIP: If you have a large number of classes that are not loaded from the cache, make sure that
|
||||
the JDK and classpath used by the commands that create the archive and start the application
|
||||
are identical. Note also that to effectively cache classes, the classpath should be specified
|
||||
as a list of JARs containing those classes, and avoid the usage of directories and `*`
|
||||
wildcard characters.
|
||||
@@ -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
|
||||
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
|
||||
`MailException`. See the {spring-framework-api}/mail/MailException.html[javadoc]
|
||||
`MailException`. See the {api-spring-framework}/mail/MailException.html[javadoc]
|
||||
for more information on the rich mail exception hierarchy.
|
||||
|
||||
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.
|
||||
The default is required only if at least one endpoint is registered without a specific
|
||||
container factory. See the javadoc of classes that implement
|
||||
{spring-framework-api}/jms/annotation/JmsListenerConfigurer.html[`JmsListenerConfigurer`]
|
||||
{api-spring-framework}/jms/annotation/JmsListenerConfigurer.html[`JmsListenerConfigurer`]
|
||||
for details and examples.
|
||||
|
||||
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
|
||||
the server-hosted `ResourceAdapter`, which also use the server's built-in `WorkManager`.
|
||||
|
||||
See the javadoc for {spring-framework-api}/jms/listener/endpoint/JmsMessageEndpointManager.html[`JmsMessageEndpointManager`],
|
||||
{spring-framework-api}/jms/listener/endpoint/JmsActivationSpecConfig.html[`JmsActivationSpecConfig`],
|
||||
and {spring-framework-api}/jca/support/ResourceAdapterFactoryBean.html[`ResourceAdapterFactoryBean`]
|
||||
See the javadoc for {api-spring-framework}/jms/listener/endpoint/JmsMessageEndpointManager.html[`JmsMessageEndpointManager`],
|
||||
{api-spring-framework}/jms/listener/endpoint/JmsActivationSpecConfig.html[`JmsActivationSpecConfig`],
|
||||
and {api-spring-framework}/jca/support/ResourceAdapterFactoryBean.html[`ResourceAdapterFactoryBean`]
|
||||
for more details.
|
||||
|
||||
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
|
||||
provider-specific `ActivationSpec` object. See your JCA provider's documentation to
|
||||
find out about the actual capabilities of your connector, and see the
|
||||
{spring-framework-api}/jca/endpoint/GenericMessageEndpointManager.html[`GenericMessageEndpointManager`]
|
||||
{api-spring-framework}/jca/endpoint/GenericMessageEndpointManager.html[`GenericMessageEndpointManager`]
|
||||
javadoc for the Spring-specific configuration details.
|
||||
|
||||
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
|
||||
of the {spring-framework-api}/jms/listener/AbstractMessageListenerContainer.html[`AbstractMessageListenerContainer`]
|
||||
of the {api-spring-framework}/jms/listener/AbstractMessageListenerContainer.html[`AbstractMessageListenerContainer`]
|
||||
and its concrete subclasses for more details on the individual properties. The javadoc
|
||||
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`
|
||||
| A reference to the `JmsActivationSpecFactory`. The default is to autodetect the JMS
|
||||
provider and its `ActivationSpec` class (see {spring-framework-api}/jms/listener/endpoint/DefaultJmsActivationSpecFactory.html[`DefaultJmsActivationSpecFactory`]).
|
||||
provider and its `ActivationSpec` class (see {api-spring-framework}/jms/listener/endpoint/DefaultJmsActivationSpecFactory.html[`DefaultJmsActivationSpecFactory`]).
|
||||
|
||||
| `destination-resolver`
|
||||
| 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
|
||||
{spring-framework-api}/jms/listener/MessageListenerContainer.html[MessageListenerContainer])
|
||||
{api-spring-framework}/jms/listener/MessageListenerContainer.html[MessageListenerContainer])
|
||||
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,
|
||||
a simple `BackOff` implementation retries every five seconds. You can specify
|
||||
a custom `BackOff` implementation for more fine-grained recovery options. See
|
||||
{spring-framework-api}/util/backoff/ExponentialBackOff.html[`ExponentialBackOff`] for an example.
|
||||
{api-spring-framework}/util/backoff/ExponentialBackOff.html[`ExponentialBackOff`] for an example.
|
||||
|
||||
NOTE: Like its sibling (xref:integration/jms/using.adoc#jms-mdp-simple[`SimpleMessageListenerContainer`]),
|
||||
`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`.
|
||||
|
||||
As stated in the javadoc of the
|
||||
{spring-framework-api}/jmx/export/notification/NotificationPublisher.html[`NotificationPublisher`]
|
||||
{api-spring-framework}/jmx/export/notification/NotificationPublisher.html[`NotificationPublisher`]
|
||||
interface, managed beans that publish events through the `NotificationPublisher`
|
||||
mechanism are not responsible for the state management of notification listeners.
|
||||
Spring's JMX support takes care of handling all the JMX infrastructure issues.
|
||||
|
||||
@@ -6,8 +6,10 @@ This section contains links to further resources about JMX:
|
||||
|
||||
* The https://www.oracle.com/technetwork/java/javase/tech/javamanagement-140525.html[JMX
|
||||
homepage] at Oracle.
|
||||
* The {JSR}003[JMX specification] (JSR-000003).
|
||||
* The {JSR}160[JMX Remote API specification] (JSR-000160).
|
||||
* The https://jcp.org/aboutJava/communityprocess/final/jsr003/index3.html[JMX
|
||||
specification] (JSR-000003).
|
||||
* 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
|
||||
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.
|
||||
|
||||
Spring Framework instruments various parts of its own codebase to publish observations if an `ObservationRegistry` is configured.
|
||||
You can learn more about {spring-boot-docs}/actuator.html#actuator.metrics[configuring the observability infrastructure in Spring Boot].
|
||||
You can learn more about {docs-spring-boot}/html/actuator.html#actuator.metrics[configuring the observability infrastructure in Spring Boot].
|
||||
|
||||
|
||||
[[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]).
|
||||
|
||||
Several implementations of `HttpMessageConverter` are described below.
|
||||
Refer to the {spring-framework-api}/http/converter/HttpMessageConverter.html[`HttpMessageConverter` Javadoc] for the complete list.
|
||||
Refer to the {api-spring-framework}/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.
|
||||
|
||||
[[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`.
|
||||
|
||||
| `MappingJackson2XmlHttpMessageConverter`
|
||||
| An `HttpMessageConverter` implementation that can read and write XML by using {jackson-github-org}/jackson-dataformat-xml[Jackson XML] extension's `XmlMapper`.
|
||||
| An `HttpMessageConverter` implementation that can read and write XML by using https://github.com/FasterXML/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.
|
||||
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`.
|
||||
@@ -401,7 +401,7 @@ You can also set the message converters to use explicitly, by using `messageConv
|
||||
|
||||
==== Jackson JSON Views
|
||||
|
||||
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:
|
||||
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:
|
||||
|
||||
[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
|
||||
fine-grained control, you can additionally implement the `SchedulingConfigurer`
|
||||
interface, the `AsyncConfigurer` interface, or both. See the
|
||||
{spring-framework-api}/scheduling/annotation/SchedulingConfigurer.html[`SchedulingConfigurer`]
|
||||
and {spring-framework-api}/scheduling/annotation/AsyncConfigurer.html[`AsyncConfigurer`]
|
||||
{api-spring-framework}/scheduling/annotation/SchedulingConfigurer.html[`SchedulingConfigurer`]
|
||||
and {api-spring-framework}/scheduling/annotation/AsyncConfigurer.html[`AsyncConfigurer`]
|
||||
javadoc for full details.
|
||||
|
||||
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
|
||||
executor's queue capacity. For the full description of the relationship between pool
|
||||
size and queue capacity, see the documentation for
|
||||
{java-api}/java.base/java/util/concurrent/ThreadPoolExecutor.html[`ThreadPoolExecutor`].
|
||||
https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ThreadPoolExecutor.html[`ThreadPoolExecutor`].
|
||||
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.
|
||||
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
|
||||
job details, properties to customize Quartz with, and a Spring-provided JDBC DataSource. See
|
||||
the {spring-framework-api}/scheduling/quartz/SchedulerFactoryBean.html[`SchedulerFactoryBean`]
|
||||
the {api-spring-framework}/scheduling/quartz/SchedulerFactoryBean.html[`SchedulerFactoryBean`]
|
||||
javadoc for more information.
|
||||
|
||||
NOTE: `SchedulerFactoryBean` also recognizes a `quartz.properties` file in the classpath,
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
= Kotlin
|
||||
:page-section-summary-toc: 1
|
||||
|
||||
{kotlin-site}[Kotlin] is a statically typed language that targets the JVM
|
||||
https://kotlinlang.org[Kotlin] is a statically typed language that targets the JVM
|
||||
(and other platforms) which allows writing concise and elegant code while providing
|
||||
very good {kotlin-docs}/java-interop.html[interoperability]
|
||||
very good https://kotlinlang.org/docs/reference/java-interop.html[interoperability]
|
||||
with existing libraries written in Java.
|
||||
|
||||
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.
|
||||
|
||||
The easiest way to build a Spring application with Kotlin is to leverage Spring Boot and
|
||||
its{spring-boot-docs}/boot-features-kotlin.html[dedicated Kotlin support].
|
||||
{spring-site-guides}/tutorials/spring-boot-kotlin/[This comprehensive tutorial]
|
||||
its https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-kotlin.html[dedicated Kotlin support].
|
||||
https://spring.io/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].
|
||||
|
||||
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
|
||||
{stackoverflow-spring-kotlin-tags}[Stackoverflow] if you need support.
|
||||
https://stackoverflow.com/questions/tagged/spring+kotlin[Stackoverflow] if you need support.
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[[kotlin-annotations]]
|
||||
= Annotations
|
||||
|
||||
The Spring Framework also takes advantage of {kotlin-docs}/null-safety.html[Kotlin null-safety]
|
||||
The Spring Framework also takes advantage of https://kotlinlang.org/docs/reference/null-safety.html[Kotlin null-safety]
|
||||
to determine if an HTTP parameter is required without having to explicitly
|
||||
define the `required` attribute. That means `@RequestParam name: String?` is treated
|
||||
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
|
||||
parameters, you may need to use
|
||||
{kotlin-docs}/annotations.html#annotation-use-site-targets[annotation use-site targets],
|
||||
https://kotlinlang.org/docs/reference/annotations.html#annotation-use-site-targets[annotation use-site targets],
|
||||
such as `@field:NotNull` or `@get:Size(min=5, max=15)`, as described in
|
||||
{stackoverflow-site}/a/35853200/1092077[this Stack Overflow response].
|
||||
https://stackoverflow.com/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
|
||||
a {spring-framework-api-kdoc}/spring-context/org.springframework.context.support/-bean-definition-dsl/index.html[Kotlin bean definition DSL]
|
||||
a {docs-spring-framework}/kdoc-api/spring-context/org.springframework.context.support/-bean-definition-dsl/index.html[Kotlin bean definition DSL]
|
||||
It declares an `ApplicationContextInitializer` through a clean declarative API,
|
||||
which lets you deal with profiles and `Environment` for customizing
|
||||
how beans are registered.
|
||||
@@ -104,10 +104,10 @@ as the following example shows:
|
||||
----
|
||||
|
||||
NOTE: Spring Boot is based on JavaConfig and
|
||||
{spring-boot-issues}/8115[does not yet provide specific support for functional bean definition],
|
||||
https://github.com/spring-projects/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.
|
||||
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 {spring-github-org}/spring-fu[Spring Fu incubator].
|
||||
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]
|
||||
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].
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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.)
|
||||
|
||||
You can declare configuration classes as
|
||||
{kotlin-docs}/nested-classes.html[top level or nested but not inner],
|
||||
https://kotlinlang.org/docs/reference/nested-classes.html[top level or nested but not inner],
|
||||
since the later requires a reference to the outer class.
|
||||
|
||||
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
[[coroutines]]
|
||||
= Coroutines
|
||||
|
||||
Kotlin {kotlin-docs}/coroutines-overview.html[Coroutines] are Kotlin
|
||||
Kotlin https://kotlinlang.org/docs/reference/coroutines-overview.html[Coroutines] are Kotlin
|
||||
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
|
||||
{kotlin-github-org}/kotlinx.coroutines[kotlinx.coroutines] provides functions like
|
||||
{kotlin-coroutines-api}/kotlinx-coroutines-core/kotlinx.coroutines/async.html[`async { }`]
|
||||
and types like {kotlin-coroutines-api}/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html[`Flow`].
|
||||
https://github.com/Kotlin/kotlinx.coroutines[kotlinx.coroutines] provides functions like
|
||||
https://kotlin.github.io/kotlinx.coroutines/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`].
|
||||
|
||||
Spring Framework provides support for Coroutines on the following scope:
|
||||
|
||||
* {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`
|
||||
* 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`
|
||||
* Suspending function support in Spring MVC and WebFlux annotated `@Controller`
|
||||
* 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 {spring-framework-api-kdoc}/spring-webflux/org.springframework.web.reactive.function.server/co-router.html[coRouter { }] DSL
|
||||
* 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.
|
||||
* WebFlux.fn {docs-spring-framework}/kdoc-api/spring-webflux/org.springframework.web.reactive.function.server/co-router.html[coRouter { }] DSL
|
||||
* Suspending function and `Flow` support in RSocket `@MessageMapping` annotated methods
|
||||
* Extensions for {spring-framework-api-kdoc}/spring-messaging/org.springframework.messaging.rsocket/index.html[`RSocketRequester`]
|
||||
* Extensions for {docs-spring-framework}/kdoc-api/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 needed, `fun handler(mono: Mono<T>)` becomes `fun handler(supplier: suspend () -> T)` or `fun handler(supplier: suspend () -> T?)`
|
||||
|
||||
{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:
|
||||
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:
|
||||
|
||||
* `Flow` is push-based while `Flux` is push-pull hybrid
|
||||
* Backpressure is implemented via suspending functions
|
||||
* `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]
|
||||
* {kotlin-github-org}/kotlinx.coroutines/tree/master/kotlinx-coroutines-core/common/src/flow/operators[Operators are easy to implement] thanks to Coroutines
|
||||
* `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]
|
||||
* https://github.com/Kotlin/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`
|
||||
* Collect operations are suspending functions
|
||||
* {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
|
||||
* 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
|
||||
|
||||
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]
|
||||
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]
|
||||
for more details, including how to run code concurrently with Coroutines.
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@ class CoroutinesViewController(banner: Banner) {
|
||||
[[webflux-fn]]
|
||||
== WebFlux.fn
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
[source,kotlin,indent=0]
|
||||
----
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
[[kotlin-extensions]]
|
||||
= Extensions
|
||||
|
||||
Kotlin {kotlin-docs}/extensions.html[extensions] provide the ability
|
||||
Kotlin https://kotlinlang.org/docs/reference/extensions.html[extensions] provide the ability
|
||||
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.
|
||||
|
||||
The {spring-framework-api-kdoc}/[Spring Framework KDoc API] lists
|
||||
The {docs-spring-framework}/kdoc-api/[Spring Framework KDoc API] lists
|
||||
and documents all available Kotlin extensions and DSLs.
|
||||
|
||||
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.
|
||||
That said, similar to static imports, an IDE should automatically suggest the import in most cases.
|
||||
|
||||
For example, {kotlin-docs}/inline-functions.html#reified-type-parameters[Kotlin reified type parameters]
|
||||
provide a workaround for JVM {java-tutorial}/java/generics/erasure.html[generics type erasure],
|
||||
For example, https://kotlinlang.org/docs/reference/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],
|
||||
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
|
||||
WebFlux, and for various other APIs.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
= Getting Started
|
||||
|
||||
The easiest way to learn how to build a Spring application with Kotlin is to follow
|
||||
{spring-site-guides}/tutorials/spring-boot-kotlin/[the dedicated tutorial].
|
||||
https://spring.io/guides/tutorials/spring-boot-kotlin/[the dedicated tutorial].
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
[[kotlin-null-safety]]
|
||||
= Null-safety
|
||||
|
||||
One of Kotlin's key features is {kotlin-docs}/null-safety.html[null-safety],
|
||||
One of Kotlin's key features is https://kotlinlang.org/docs/reference/null-safety.html[null-safety],
|
||||
which cleanly deals with `null` values at compile time rather than bumping into the famous
|
||||
`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`.
|
||||
(Kotlin allows using functional constructs with nullable values. See this
|
||||
{baeldung-blog}/kotlin-null-safety[comprehensive guide to Kotlin null-safety].)
|
||||
https://www.baeldung.com/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
|
||||
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.
|
||||
By default, types from Java APIs used in Kotlin are recognized as
|
||||
{kotlin-docs}/java-interop.html#null-safety-and-platform-types[platform types],
|
||||
https://kotlinlang.org/docs/reference/java-interop.html#null-safety-and-platform-types[platform types],
|
||||
for which null-checks are relaxed.
|
||||
{kotlin-docs}/java-interop.html#jsr-305-support[Kotlin support for JSR-305 annotations]
|
||||
https://kotlinlang.org/docs/reference/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,
|
||||
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.
|
||||
|
||||
NOTE: Generic type arguments, varargs, and array elements nullability are not supported yet,
|
||||
but should be in an upcoming release. See {kotlin-github-org}/KEEP/issues/79[this discussion]
|
||||
but should be in an upcoming release. See https://github.com/Kotlin/KEEP/issues/79[this discussion]
|
||||
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
|
||||
https://start.spring.io/#!language=kotlin&type=gradle-project[start.spring.io].
|
||||
|
||||
WARNING: Kotlin {kotlin-docs}/inline-classes.html[inline classes] are not yet supported.
|
||||
WARNING: Kotlin https://kotlinlang.org/docs/inline-classes.html[inline classes] are not yet supported.
|
||||
|
||||
NOTE: The {jackson-github-org}/jackson-module-kotlin[Jackson Kotlin module] is required
|
||||
NOTE: The https://github.com/FasterXML/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
|
||||
`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.
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
We recommend the following resources for people learning how to build applications with
|
||||
Kotlin and the Spring Framework:
|
||||
|
||||
* {kotlin-docs}[Kotlin language reference]
|
||||
* https://kotlinlang.org/docs/reference/[Kotlin language reference]
|
||||
* https://slack.kotlinlang.org/[Kotlin Slack] (with a dedicated #spring channel)
|
||||
* {stackoverflow-spring-kotlin-tags}[Stackoverflow, with `spring` and `kotlin` tags]
|
||||
* https://stackoverflow.com/questions/tagged/spring+kotlin[Stackoverflow, with `spring` and `kotlin` tags]
|
||||
* https://play.kotlinlang.org/[Try Kotlin in your browser]
|
||||
* https://blog.jetbrains.com/kotlin/[Kotlin blog]
|
||||
* 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:
|
||||
|
||||
* Spring Framework
|
||||
** {spring-framework-issues}/20606[Unable to use WebTestClient with mock server in Kotlin]
|
||||
** {spring-framework-issues}/20496[Support null-safety at generics, varargs and array elements level]
|
||||
** https://github.com/spring-projects/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]
|
||||
* Kotlin
|
||||
** {kotlin-issues}/KT-6380[Parent issue for Spring Framework support]
|
||||
** {kotlin-issues}/KT-5464[Kotlin requires type inference where Java doesn't]
|
||||
** {kotlin-issues}/KT-20283[Smart cast regression with open classes]
|
||||
** {kotlin-issues}/KT-14984[Impossible to pass not all SAM argument as function]
|
||||
** {kotlin-issues}/KT-15125[Support JSR 223 bindings directly via script variables]
|
||||
** {kotlin-issues}/KT-6653[Kotlin properties do not override Java-style getters and setters]
|
||||
** https://youtrack.jetbrains.com/issue/KT-6380[Parent issue for Spring Framework support]
|
||||
** https://youtrack.jetbrains.com/issue/KT-5464[Kotlin requires type inference where Java doesn't]
|
||||
** https://youtrack.jetbrains.com/issue/KT-20283[Smart cast regression with open classes]
|
||||
** https://youtrack.jetbrains.com/issue/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]
|
||||
** https://youtrack.jetbrains.com/issue/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.
|
||||
|
||||
NOTE: It is also possible to avoid CGLIB proxies for configuration classes by using `@Configuration(proxyBeanMethods = false)`.
|
||||
See {spring-framework-api}/context/annotation/Configuration.html#proxyBeanMethods--[`proxyBeanMethods` Javadoc] for more details.
|
||||
See {api-spring-framework}/context/annotation/Configuration.html#proxyBeanMethods--[`proxyBeanMethods` Javadoc] for more details.
|
||||
|
||||
Fortunately, Kotlin provides a
|
||||
{kotlin-docs}/compiler-plugins.html#kotlin-spring-compiler-plugin[`kotlin-spring`]
|
||||
https://kotlinlang.org/docs/reference/compiler-plugins.html#kotlin-spring-compiler-plugin[`kotlin-spring`]
|
||||
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
|
||||
annotations:
|
||||
@@ -59,7 +59,7 @@ within the primary constructor, as in the following example:
|
||||
class Person(val name: String, val age: Int)
|
||||
----
|
||||
|
||||
You can optionally add {kotlin-docs}/data-classes.html[the `data` keyword]
|
||||
You can optionally add https://kotlinlang.org/docs/reference/data-classes.html[the `data` keyword]
|
||||
to make the compiler automatically derive the following members from all properties declared
|
||||
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
|
||||
kind of design. Fortunately, there is a workaround for this
|
||||
{stackoverflow-questions}/32038177/kotlin-with-jpa-default-constructor-hell["`default constructor hell`"],
|
||||
since Kotlin provides a {kotlin-docs}/compiler-plugins.html#kotlin-jpa-compiler-plugin[`kotlin-jpa`]
|
||||
https://stackoverflow.com/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`]
|
||||
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
|
||||
the {kotlin-docs}/compiler-plugins.html#how-to-use-no-arg-plugin[`kotlin-noarg`]
|
||||
the https://kotlinlang.org/docs/reference/compiler-plugins.html#how-to-use-no-arg-plugin[`kotlin-noarg`]
|
||||
plugin.
|
||||
|
||||
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
|
||||
|
||||
Our recommendation is to try to favor constructor injection with `val` read-only (and
|
||||
non-nullable when possible) {kotlin-docs}/properties.html[properties],
|
||||
non-nullable when possible) https://kotlinlang.org/docs/reference/properties.html[properties],
|
||||
as the following example shows:
|
||||
|
||||
[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}")`)].
|
||||
However, in Kotlin, `$` is a reserved character that is used for
|
||||
{kotlin-docs}/idioms.html#string-interpolation[string interpolation].
|
||||
https://kotlinlang.org/docs/reference/idioms.html#string-interpolation[string interpolation].
|
||||
|
||||
Therefore, if you wish to use the `@Value` annotation in Kotlin, you need to escape the `$`
|
||||
character by writing pass:q[`@Value("\${property}")`].
|
||||
|
||||
NOTE: If you use Spring Boot, you should probably use
|
||||
{spring-boot-docs}/boot-features-external-config.html#boot-features-external-config-typesafe-configuration-properties[`@ConfigurationProperties`]
|
||||
https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html#boot-features-external-config-typesafe-configuration-properties[`@ConfigurationProperties`]
|
||||
instead of `@Value` annotations.
|
||||
|
||||
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
|
||||
|
||||
Java and {kotlin-docs}/exceptions.html[Kotlin exception handling]
|
||||
Java and https://kotlinlang.org/docs/reference/exceptions.html[Kotlin exception handling]
|
||||
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
|
||||
annotated with `@Transactional`), checked exceptions thrown will be wrapped by default in
|
||||
an `UndeclaredThrowableException`.
|
||||
|
||||
To get the original exception thrown like in Java, methods should be annotated with
|
||||
{kotlin-api}/jvm/stdlib/kotlin.jvm/-throws/index.html[`@Throws`]
|
||||
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-throws/index.html[`@Throws`]
|
||||
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
|
||||
extensively used in Spring) behave differently. As explained in the
|
||||
{kotlin-docs}/annotations.html[Kotlin documentation] you can omit
|
||||
https://kotlinlang.org/docs/reference/annotations.html[Kotlin documentation] you can omit
|
||||
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
|
||||
@@ -240,13 +240,13 @@ be matched, not only the `GET` method.
|
||||
== Declaration-site variance
|
||||
|
||||
Dealing with generic types in Spring applications written in Kotlin may require, for some use cases, to understand
|
||||
Kotlin {kotlin-docs}/generics.html#declaration-site-variance[declaration-site variance]
|
||||
Kotlin https://kotlinlang.org/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
|
||||
variance.
|
||||
|
||||
For example, declaring `List<Foo>` in Kotlin is conceptually equivalent to `java.util.List<? extends Foo>` because
|
||||
`kotlin.collections.List` is declared as
|
||||
{kotlin-api}/jvm/stdlib/kotlin.collections/-list/[`interface List<out E> : kotlin.collections.Collection<E>`].
|
||||
https://kotlinlang.org/api/latest/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,
|
||||
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,
|
||||
subscribe to {spring-framework-issues}/22313[spring-framework#22313] to track related
|
||||
subscribe to https://github.com/spring-projects/spring-framework/issues/22313[spring-framework#22313] to track related
|
||||
progresses.
|
||||
|
||||
|
||||
@@ -280,7 +280,7 @@ The recommended testing framework is https://junit.org/junit5/[JUnit 5] along wi
|
||||
https://mockk.io/[Mockk] for mocking.
|
||||
|
||||
NOTE: If you are using Spring Boot, see
|
||||
{spring-boot-docs}/features.html#features.kotlin.testing[this related documentation].
|
||||
https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-kotlin-testing[this related documentation].
|
||||
|
||||
|
||||
[[constructor-injection]]
|
||||
@@ -289,7 +289,7 @@ NOTE: If you are using Spring Boot, see
|
||||
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
|
||||
in order to use `val` instead of `lateinit var`. You can use
|
||||
{spring-framework-api}/test/context/TestConstructor.html[`@TestConstructor(autowireMode = AutowireMode.ALL)`]
|
||||
{api-spring-framework}/test/context/TestConstructor.html[`@TestConstructor(autowireMode = AutowireMode.ALL)`]
|
||||
to enable autowiring for all parameters.
|
||||
|
||||
NOTE: You can also change the default behavior to `ALL` in a `junit-platform.properties`
|
||||
@@ -383,3 +383,15 @@ class SpecificationLikeTests {
|
||||
----
|
||||
|
||||
|
||||
[[kotlin-webtestclient-issue]]
|
||||
=== `WebTestClient` Type Inference Issue in Kotlin
|
||||
|
||||
Due to a https://youtrack.jetbrains.com/issue/KT-5464[type inference issue], you must
|
||||
use the Kotlin `expectBody` extension (such as `.expectBody<String>().isEqualTo("toys")`),
|
||||
since it provides a workaround for the Kotlin issue with the Java API.
|
||||
|
||||
See also the related https://jira.spring.io/browse/SPR-16057[SPR-16057] issue.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
|
||||
Spring Framework comes with a Kotlin router DSL available in 3 flavors:
|
||||
|
||||
* 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 {spring-framework-api-kdoc}/spring-webflux/org.springframework.web.reactive.function.server/router.html[router { }]
|
||||
* WebFlux.fn <<Coroutines>> DSL with {spring-framework-api-kdoc}/spring-webflux/org.springframework.web.reactive.function.server/co-router.html[coRouter { }]
|
||||
* WebMvc.fn DSL with {docs-spring-framework}/kdoc-api/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 <<Coroutines>> DSL with {docs-spring-framework}/kdoc-api/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:
|
||||
|
||||
@@ -79,12 +79,12 @@ mockMvc.get("/person/{name}", "Lee") {
|
||||
== Kotlin Script Templates
|
||||
|
||||
Spring Framework provides a
|
||||
{spring-framework-api}/web/servlet/view/script/ScriptTemplateView.html[`ScriptTemplateView`]
|
||||
which supports {JSR}223[JSR-223] to render templates by using script engines.
|
||||
https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/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.
|
||||
|
||||
By leveraging `scripting-jsr223` dependencies, it
|
||||
is possible to use such feature to render Kotlin-based templates with
|
||||
{kotlin-github-org}/kotlinx.html[kotlinx.html] DSL or Kotlin multiline interpolated `String`.
|
||||
https://github.com/Kotlin/kotlinx.html[kotlinx.html] DSL or Kotlin multiline interpolated `String`.
|
||||
|
||||
`build.gradle.kts`
|
||||
[source,kotlin,indent=0]
|
||||
@@ -126,10 +126,10 @@ project for more details.
|
||||
[[kotlin-multiplatform-serialization]]
|
||||
== Kotlin multiplatform serialization
|
||||
|
||||
As of Spring Framework 5.3, {kotlin-github-org}/kotlinx.serialization[Kotlin multiplatform serialization] is
|
||||
As of Spring Framework 5.3, https://github.com/Kotlin/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.
|
||||
|
||||
To enable it, follow {kotlin-github-org}/kotlinx.serialization#setup[those instructions] to add the related dependency and plugin.
|
||||
To enable it, follow https://github.com/Kotlin/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
|
||||
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,
|
||||
|
||||
@@ -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
|
||||
with carefully selected individual specifications from the traditional EE umbrella:
|
||||
|
||||
* Servlet API ({JSR}340[JSR 340])
|
||||
* WebSocket API ({JSR}356[JSR 356])
|
||||
* Concurrency Utilities ({JSR}236[JSR 236])
|
||||
* JSON Binding API ({JSR}367[JSR 367])
|
||||
* Bean Validation ({JSR}303[JSR 303])
|
||||
* JPA ({JSR}338[JSR 338])
|
||||
* JMS ({JSR}914[JSR 914])
|
||||
* Servlet API (https://jcp.org/en/jsr/detail?id=340[JSR 340])
|
||||
* WebSocket API (https://www.jcp.org/en/jsr/detail?id=356[JSR 356])
|
||||
* Concurrency Utilities (https://www.jcp.org/en/jsr/detail?id=236[JSR 236])
|
||||
* JSON Binding API (https://jcp.org/en/jsr/detail?id=367[JSR 367])
|
||||
* Bean Validation (https://jcp.org/en/jsr/detail?id=303[JSR 303])
|
||||
* JPA (https://jcp.org/en/jsr/detail?id=338[JSR 338])
|
||||
* JMS (https://jcp.org/en/jsr/detail?id=914[JSR 914])
|
||||
* as well as JTA/JCA setups for transaction coordination, if necessary.
|
||||
|
||||
The Spring Framework also supports the Dependency Injection
|
||||
({JSR}330[JSR 330]) and Common Annotations
|
||||
({JSR}250[JSR 250]) specifications, which application
|
||||
(https://www.jcp.org/en/jsr/detail?id=330[JSR 330]) and Common Annotations
|
||||
(https://jcp.org/en/jsr/detail?id=250[JSR 250]) specifications, which application
|
||||
developers may choose to use instead of the Spring-specific mechanisms provided
|
||||
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
|
||||
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,
|
||||
issue tracker, and release cadence. See {spring-site-projects}[spring.io/projects] for
|
||||
issue tracker, and release cadence. See https://spring.io/projects[spring.io/projects] for
|
||||
the complete list of Spring projects.
|
||||
|
||||
|
||||
@@ -125,17 +125,17 @@ clean code structure with no circular dependencies between packages.
|
||||
== Feedback and Contributions
|
||||
|
||||
For how-to questions or diagnosing or debugging issues, we suggest using Stack Overflow. Click
|
||||
{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]
|
||||
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]
|
||||
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
|
||||
the {spring-framework-issues}[GitHub Issues].
|
||||
the https://github.com/spring-projects/spring-framework/issues[GitHub Issues].
|
||||
|
||||
If you have a solution in mind or a suggested fix, you can submit a pull request on
|
||||
{spring-framework-github}[Github]. However, please keep in mind
|
||||
https://github.com/spring-projects/spring-framework[Github]. However, please keep in mind
|
||||
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.
|
||||
|
||||
For more details see the guidelines at the {spring-framework-code}/CONTRIBUTING.md[CONTRIBUTING],
|
||||
For more details see the guidelines at the {spring-framework-main-code}/CONTRIBUTING.md[CONTRIBUTING],
|
||||
top-level project page.
|
||||
|
||||
|
||||
@@ -145,15 +145,15 @@ top-level project page.
|
||||
== Getting Started
|
||||
|
||||
If you are just getting started with Spring, you may want to begin using the Spring
|
||||
Framework by creating a {spring-site-projects}/spring-boot/[Spring Boot]-based
|
||||
Framework by creating a https://projects.spring.io/spring-boot/[Spring Boot]-based
|
||||
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
|
||||
convention over configuration, and is designed to get you up and running as quickly
|
||||
as possible.
|
||||
|
||||
You can use https://start.spring.io/[start.spring.io] to generate a basic project or follow
|
||||
one of the {spring-site-guides}["Getting Started" guides], such as
|
||||
{spring-site-guides}/gs/rest-service/[Getting Started Building a RESTful Web Service].
|
||||
one of the https://spring.io/guides["Getting Started" guides], such as
|
||||
https://spring.io/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
|
||||
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.
|
||||
|
||||
@@ -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:
|
||||
|
||||
* {reactive-streams-site}/[Reactive Streams] semantics across network boundary --
|
||||
* https://www.reactive-streams.org/[Reactive Streams] semantics across network boundary --
|
||||
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
|
||||
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.
|
||||
* Keepalive (heartbeats).
|
||||
|
||||
RSocket has {rsocket-github-org}[implementations] in multiple languages. The
|
||||
{rsocket-java}[Java library] is built on {reactor-site}/[Project Reactor],
|
||||
and {reactor-github-org}/reactor-netty[Reactor Netty] for the transport. That means
|
||||
RSocket has {gh-rsocket}[implementations] in multiple languages. The
|
||||
{gh-rsocket-java}[Java library] is built on https://projectreactor.io/[Project Reactor],
|
||||
and https://github.com/reactor/reactor-netty[Reactor Netty] for the transport. That means
|
||||
signals from Reactive Streams Publishers in your application propagate transparently
|
||||
through RSocket across the network.
|
||||
|
||||
@@ -50,8 +50,8 @@ through RSocket across the network.
|
||||
=== The Protocol
|
||||
|
||||
One of the benefits of RSocket is that it has well defined behavior on the wire and an
|
||||
easy to read {rsocket-site}/about/protocol[specification] along with some protocol
|
||||
{rsocket-protocol-extensions}[extensions]. Therefore it is
|
||||
easy to read https://rsocket.io/about/protocol[specification] along with some protocol
|
||||
{gh-rsocket}/rsocket/tree/master/Extensions[extensions]. Therefore it is
|
||||
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.
|
||||
|
||||
@@ -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:
|
||||
|
||||
* {rsocket-protocol-extensions}/CompositeMetadata.md[Composite Metadata]-- multiple,
|
||||
* {gh-rsocket-extensions}/CompositeMetadata.md[Composite Metadata]-- multiple,
|
||||
independently formatted metadata entries.
|
||||
* {rsocket-protocol-extensions}/Routing.md[Routing] -- the route for a request.
|
||||
* {gh-rsocket-extensions}/Routing.md[Routing] -- the route for a request.
|
||||
|
||||
|
||||
|
||||
[[rsocket-java]]
|
||||
=== Java Implementation
|
||||
|
||||
The {rsocket-java}[Java implementation] for RSocket is built on
|
||||
{reactor-site}/[Project Reactor]. The transports for TCP and WebSocket are
|
||||
built on {reactor-github-org}/reactor-netty[Reactor Netty]. As a Reactive Streams
|
||||
The {gh-rsocket-java}[Java implementation] for RSocket is built on
|
||||
https://projectreactor.io/[Project Reactor]. The transports for TCP and WebSocket are
|
||||
built on https://github.com/reactor/reactor-netty[Reactor Netty]. As a Reactive Streams
|
||||
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
|
||||
pressure support.
|
||||
@@ -117,7 +117,7 @@ features and leaves the application programming model (e.g. RPC codegen vs other
|
||||
higher level, independent concern.
|
||||
|
||||
The main contract
|
||||
{rsocket-java-code}/rsocket-core/src/main/java/io/rsocket/RSocket.java[io.rsocket.RSocket]
|
||||
{gh-rsocket-java}/blob/master/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
|
||||
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
|
||||
@@ -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
|
||||
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
|
||||
{rsocket-java-code}/rsocket-examples[sample apps] that
|
||||
{gh-rsocket-java}/tree/master/rsocket-examples[sample apps] that
|
||||
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
|
||||
support and auto-configuration for an `RSocketRequester.Builder` and `RSocketStrategies`.
|
||||
See the
|
||||
{spring-boot-docs}/messaging.html#messaging.rsocket[RSocket section]
|
||||
https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-rsocket[RSocket section]
|
||||
in the Spring Boot reference for more details.
|
||||
|
||||
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
|
||||
metadata, the default mime type is
|
||||
{rsocket-protocol-extensions}/CompositeMetadata.md[composite metadata] which allows multiple
|
||||
{gh-rsocket-extensions}/CompositeMetadata.md[composite metadata] which allows multiple
|
||||
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,
|
||||
@@ -534,7 +534,7 @@ Kotlin::
|
||||
======
|
||||
|
||||
Extra metadata values can be added if using
|
||||
{rsocket-protocol-extensions}/CompositeMetadata.md[composite metadata] (the default) and if the
|
||||
{gh-rsocket-extensions}/CompositeMetadata.md[composite metadata] (the default) and if the
|
||||
values are supported by a registered `Encoder`. For example:
|
||||
|
||||
[tabs]
|
||||
@@ -663,8 +663,8 @@ Kotlin::
|
||||
======
|
||||
|
||||
`RSocketMessageHandler` supports
|
||||
{rsocket-protocol-extensions}/CompositeMetadata.md[composite] and
|
||||
{rsocket-protocol-extensions}/Routing.md[routing] metadata by default. You can set its
|
||||
{gh-rsocket-extensions}/CompositeMetadata.md[composite] and
|
||||
{gh-rsocket-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
|
||||
different mime type or register additional metadata mime types.
|
||||
|
||||
@@ -954,7 +954,7 @@ xref:rsocket.adoc#rsocket-requester-server[Server Requester] for details.
|
||||
== MetadataExtractor
|
||||
|
||||
Responders must interpret metadata.
|
||||
{rsocket-protocol-extensions}/CompositeMetadata.md[Composite metadata] allows independently
|
||||
{gh-rsocket-extensions}/CompositeMetadata.md[Composite metadata] allows independently
|
||||
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
|
||||
to access extracted values.
|
||||
@@ -965,7 +965,7 @@ in annotated handler methods.
|
||||
|
||||
`DefaultMetadataExtractor` can be given `Decoder` instances to decode metadata. Out of
|
||||
the box it has built-in support for
|
||||
{rsocket-protocol-extensions}/Routing.md["message/x.rsocket.routing.v0"] which it decodes to
|
||||
{gh-rsocket-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
|
||||
a `Decoder` and register the mime type as follows:
|
||||
|
||||
|
||||
+4
-4
@@ -82,7 +82,7 @@ Kotlin::
|
||||
|
||||
|
||||
See xref:testing/testcontext-framework/ctx-management.adoc[Context Management] as well as the javadoc for
|
||||
{spring-framework-api}/test/context/junit/jupiter/SpringJUnitConfig.html[`@SpringJUnitConfig`]
|
||||
{api-spring-framework}/test/context/junit/jupiter/SpringJUnitConfig.html[`@SpringJUnitConfig`]
|
||||
and `@ContextConfiguration` for further details.
|
||||
|
||||
[[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
|
||||
{spring-framework-api}/test/context/junit/jupiter/web/SpringJUnitWebConfig.html[`@SpringJUnitWebConfig`],
|
||||
{spring-framework-api}/test/context/ContextConfiguration.html[`@ContextConfiguration`], and
|
||||
{spring-framework-api}/test/context/web/WebAppConfiguration.html[`@WebAppConfiguration`]
|
||||
{api-spring-framework}/test/context/junit/jupiter/web/SpringJUnitWebConfig.html[`@SpringJUnitWebConfig`],
|
||||
{api-spring-framework}/test/context/ContextConfiguration.html[`@ContextConfiguration`], and
|
||||
{api-spring-framework}/test/context/web/WebAppConfiguration.html[`@WebAppConfiguration`]
|
||||
for further details.
|
||||
|
||||
[[integration-testing-annotations-testconstructor]]
|
||||
|
||||
@@ -305,5 +305,5 @@ Kotlin::
|
||||
======
|
||||
|
||||
For further details, see the
|
||||
{spring-framework-wiki}/Spring-Annotation-Programming-Model[Spring Annotation Programming Model]
|
||||
https://github.com/spring-projects/spring-framework/wiki/Spring-Annotation-Programming-Model[Spring Annotation Programming Model]
|
||||
wiki page.
|
||||
|
||||
+1
-1
@@ -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],
|
||||
xref:testing/testcontext-framework/support-classes.adoc#testcontext-junit-jupiter-nested-test-configuration[`@Nested` test class configuration], and the
|
||||
{spring-framework-api}/test/context/ActiveProfiles.html[`@ActiveProfiles`] javadoc for
|
||||
{api-spring-framework}/test/context/ActiveProfiles.html[`@ActiveProfiles`] javadoc for
|
||||
examples and further details.
|
||||
|
||||
|
||||
+1
-1
@@ -40,6 +40,6 @@ Kotlin::
|
||||
By default, `@ContextCustomizerFactories` provides support for inheriting factories from
|
||||
superclasses or enclosing classes. See
|
||||
xref:testing/testcontext-framework/support-classes.adoc#testcontext-junit-jupiter-nested-test-configuration[`@Nested` test class configuration] and the
|
||||
{spring-framework-api}/test/context/ContextCustomizerFactories.html[`@ContextCustomizerFactories`
|
||||
{api-spring-framework}/test/context/ContextCustomizerFactories.html[`@ContextCustomizerFactories`
|
||||
javadoc] for an example and further details.
|
||||
|
||||
|
||||
+1
-1
@@ -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
|
||||
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
|
||||
{spring-framework-api}/test/context/ContextHierarchy.html[`@ContextHierarchy`] javadoc
|
||||
{api-spring-framework}/test/context/ContextHierarchy.html[`@ContextHierarchy`] javadoc
|
||||
for further examples.
|
||||
|
||||
|
||||
+1
-1
@@ -257,6 +257,6 @@ Kotlin::
|
||||
|
||||
|
||||
For further details regarding the `EXHAUSTIVE` and `CURRENT_LEVEL` algorithms, see the
|
||||
{spring-framework-api}/test/annotation/DirtiesContext.HierarchyMode.html[`DirtiesContext.HierarchyMode`]
|
||||
{api-spring-framework}/test/annotation/DirtiesContext.HierarchyMode.html[`DirtiesContext.HierarchyMode`]
|
||||
javadoc.
|
||||
|
||||
|
||||
+1
-1
@@ -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
|
||||
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
|
||||
{testcontainers-site}[Testcontainers] project.
|
||||
https://www.testcontainers.org/[Testcontainers] project.
|
||||
|
||||
The following example demonstrates how to register a dynamic property:
|
||||
|
||||
|
||||
+1
-1
@@ -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.
|
||||
|
||||
See xref:testing/testcontext-framework/application-events.adoc[Application Events] and the
|
||||
{spring-framework-api}/test/context/event/RecordApplicationEvents.html[`@RecordApplicationEvents`
|
||||
{api-spring-framework}/test/context/event/RecordApplicationEvents.html[`@RecordApplicationEvents`
|
||||
javadoc] for an example and further details.
|
||||
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ Kotlin::
|
||||
By default, `@TestExecutionListeners` provides support for inheriting listeners from
|
||||
superclasses or enclosing classes. See
|
||||
xref:testing/testcontext-framework/support-classes.adoc#testcontext-junit-jupiter-nested-test-configuration[`@Nested` test class configuration] and the
|
||||
{spring-framework-api}/test/context/TestExecutionListeners.html[`@TestExecutionListeners`
|
||||
{api-spring-framework}/test/context/TestExecutionListeners.html[`@TestExecutionListeners`
|
||||
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
|
||||
in xref:testing/testcontext-framework/tel-config.adoc#testcontext-tel-config-registering-tels[Registering `TestExecutionListener` Implementations].
|
||||
|
||||
+1
-1
@@ -80,6 +80,6 @@ Kotlin::
|
||||
Note that `@WebAppConfiguration` must be used in conjunction with
|
||||
`@ContextConfiguration`, either within a single test class or within a test class
|
||||
hierarchy. See the
|
||||
{spring-framework-api}/test/context/web/WebAppConfiguration.html[`@WebAppConfiguration`]
|
||||
{api-spring-framework}/test/context/web/WebAppConfiguration.html[`@WebAppConfiguration`]
|
||||
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
|
||||
for test groups, data-driven testing, distributed testing, and other features. Supported
|
||||
in the xref:testing/testcontext-framework.adoc[Spring TestContext Framework]
|
||||
* {assertj-docs}[AssertJ]: "Fluent assertions for Java",
|
||||
* https://assertj.github.io/doc/[AssertJ]: "Fluent assertions for Java",
|
||||
including support for Java 8 lambdas, streams, and numerous other features.
|
||||
* 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
|
||||
@@ -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
|
||||
is targeted at database-driven projects and, among other things, puts your database into
|
||||
a known state between test runs.
|
||||
* {testcontainers-site}[Testcontainers]: Java library that supports JUnit
|
||||
* https://www.testcontainers.org/[Testcontainers]: Java library that supports JUnit
|
||||
tests, providing lightweight, throwaway instances of common databases, Selenium web
|
||||
browsers, or anything else that can run in a Docker container.
|
||||
* 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
|
||||
|
||||
Spring MVC Test's own tests include
|
||||
{spring-framework-code}/spring-test/src/test/java/org/springframework/test/web/client/samples[example
|
||||
{spring-framework-main-code}/spring-test/src/test/java/org/springframework/test/web/client/samples[example
|
||||
tests] of client-side REST tests.
|
||||
|
||||
+3
-3
@@ -184,7 +184,7 @@ Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||
----
|
||||
// Not possible in Kotlin until {kotlin-issues}/KT-22208 is fixed
|
||||
// Not possible in Kotlin until https://youtrack.jetbrains.com/issue/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.
|
||||
|
||||
When a JSON response content contains hypermedia links created with
|
||||
{spring-github-org}/spring-hateoas[Spring HATEOAS], you can verify the
|
||||
https://github.com/spring-projects/spring-hateoas[Spring HATEOAS], you can verify the
|
||||
resulting links by using JsonPath expressions, as the following example shows:
|
||||
|
||||
[tabs]
|
||||
@@ -220,7 +220,7 @@ Kotlin::
|
||||
======
|
||||
|
||||
When XML response content contains hypermedia links created with
|
||||
{spring-github-org}/spring-hateoas[Spring HATEOAS], you can verify the
|
||||
https://github.com/spring-projects/spring-hateoas[Spring HATEOAS], you can verify the
|
||||
resulting links by using XPath expressions:
|
||||
|
||||
[tabs]
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||
----
|
||||
// Not possible in Kotlin until {kotlin-issues}/KT-22208 is fixed
|
||||
// Not possible in Kotlin until https://youtrack.jetbrains.com/issue/KT-22208 is fixed
|
||||
----
|
||||
======
|
||||
|
||||
|
||||
+2
-2
@@ -113,7 +113,7 @@ Kotlin::
|
||||
======
|
||||
|
||||
Finally, we can verify that a new message was created successfully. The following
|
||||
assertions use the {assertj-docs}[AssertJ] library:
|
||||
assertions use the https://assertj.github.io/doc/[AssertJ] library:
|
||||
|
||||
[tabs]
|
||||
======
|
||||
@@ -268,7 +268,7 @@ Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||
----
|
||||
// Not possible in Kotlin until {kotlin-issues}/KT-22208 is fixed
|
||||
// Not possible in Kotlin until https://youtrack.jetbrains.com/issue/KT-22208 is fixed
|
||||
----
|
||||
======
|
||||
|
||||
|
||||
+2
-2
@@ -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
|
||||
assertions use the {assertj-docs}[AssertJ] assertion library:
|
||||
assertions use the https://assertj.github.io/doc/[AssertJ] assertion library:
|
||||
|
||||
--
|
||||
[tabs]
|
||||
@@ -562,7 +562,7 @@ Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||
----
|
||||
// Not possible in Kotlin until {kotlin-issues}/KT-22208 is fixed
|
||||
// Not possible in Kotlin until https://youtrack.jetbrains.com/issue/KT-22208 is fixed
|
||||
----
|
||||
======
|
||||
|
||||
|
||||
+1
-1
@@ -159,7 +159,7 @@ Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||
----
|
||||
// Not possible in Kotlin until {kotlin-issues}/KT-22208 is fixed
|
||||
// Not possible in Kotlin until https://youtrack.jetbrains.com/issue/KT-22208 is fixed
|
||||
----
|
||||
======
|
||||
|
||||
|
||||
+2
-2
@@ -3,9 +3,9 @@
|
||||
:page-section-summary-toc: 1
|
||||
|
||||
The framework's own tests include
|
||||
{spring-framework-code}/spring-test/src/test/java/org/springframework/test/web/servlet/samples[
|
||||
{spring-framework-main-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
|
||||
{spring-framework-code}/spring-test/src/test/java/org/springframework/test/web/servlet/samples/client[
|
||||
{spring-framework-main-code}/spring-test/src/test/java/org/springframework/test/web/servlet/samples/client[
|
||||
WebTestClient]. Browse these examples for further ideas.
|
||||
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user