Commit Graph

612 Commits

Author SHA1 Message Date
Stéphane Nicoll bd61da12b2 Merge branch '6.1.x' 2024-08-09 09:05:12 +02:00
Stéphane Nicoll df7ac9b308 Polish "Fix error codes in Customizing Validation Errors section"
See gh-33354
2024-08-09 09:03:05 +02:00
Gonçalo Silva 43217bdf06 Fix error codes in Customizing Validation Errors section
See gh-33354
2024-08-09 09:02:53 +02:00
Sam Brannen cd7c650941 Merge branch '6.1.x' 2024-08-08 17:16:19 +03:00
Robert Danczak a31945f8b6 Fix syntax error in RestClient documentation
Closes gh-33350
2024-08-08 17:15:27 +03:00
rstoyanchev e670c6b50a Documentation updates for fragment rendering
Closes gh-33195
2024-08-08 16:25:03 +03:00
rstoyanchev 0bac8d48a5 Polishing in view rendering documentation
See gh-33195
2024-08-08 16:25:03 +03:00
Stéphane Nicoll 4ceefa7501 Merge branch '6.1.x' 2024-08-08 11:41:53 +02:00
Paul-Christian Volkmer 7e4884fcfa Add missing Kotlin example for expectAll()
See gh-33341
2024-08-08 11:35:12 +02:00
Simon Baslé 1c893e6354 Add `@MockitoBeanSettings`, use MockitoSession with strict stubs default
This commit changes the way the `MockitoTestExecutionListener` sets up
mockito, now using the `MockitoSession` feature. Additionally, stubbing
now defaults to a STRICT mode which can be overruled with a newly
introduced annotation: `@MockitoBeanSettings`.

Closes gh-33318
2024-08-07 14:57:15 +02:00
Brian Clozel 38453910cd Add DatabaseClient bind variant for list of parameters
Prior to this commit, the `DatabaseClient` interface would allow batch
operations for binding parameters by their names and values. Positional
parameters did not have such equivalent.

This commit adds a new `bindValues(List<?>)` method variant for adding
multiple positional arguments in a single call and avoiding allocation
overhead when the parameters count is large.

Closes gh-33274
2024-07-29 14:07:15 +02:00
Stéphane Nicoll 46ba13b645 Review Caching infrastructure documentation
Closes gh-33288
2024-07-29 11:29:35 +02:00
Stéphane Nicoll de2335bee3 Merge branch '6.1.x' 2024-07-26 10:05:06 +02:00
Stéphane Nicoll ea665d776d Polish "Fix reference to configurePathMatching in code sample"
See gh-33277
2024-07-26 10:01:39 +02:00
sheip9 7a2fc2ff09 Fix reference to configurePathMatching in code sample
See gh-33277
2024-07-26 10:01:21 +02:00
Simon Baslé c92e043bbc Support multiple style of parsing/printing Durations
This commit introduces a notion of different styles for the formatting
of Duration.
The `@DurationFormat` annotation is added to ease selection of a style,
which are represented as DurationFormat.Style enum, as well as a
supported time unit represented as DurationFormat.Unit enum.

DurationFormatter has been retroffited to take such a Style,
optionally, at construction. The default is still the JDK style a.k.a.
ISO-8601.

This introduces the new SIMPLE style which uses a single number + a
short human-readable suffix. For instance "-3ms" or "2h".

This has the same semantics as the DurationStyle in Spring Boot and
is intended as a replacement for that feature, providing access to the
feature to projects that only depend on Spring Framework.

Finally, the `@Scheduled` annotation is improved by adding detection
of the style and parsing for the String versions of initial delay, fixed
delay and fixed rate.

See gh-22013
See gh-22474

Closes gh-30396
2024-07-23 11:56:48 +02:00
Stéphane Nicoll 2190c6ec79 Merge branch '6.1.x' 2024-07-21 11:42:39 +02:00
Stéphane Nicoll af8dc44469 Polish "Stop referring to STRUCT and ARRAY as they are deprecated"
See gh-33248
2024-07-21 11:39:16 +02:00
Tran Ngoc Nhan 955602bdbd Stop referring to STRUCT and ARRAY as they are deprecated
See gh-33248
2024-07-21 11:18:12 +02:00
Stéphane Nicoll 97411ddd55 Merge branch '6.1.x' 2024-07-20 11:53:31 +02:00
Stéphane Nicoll a3b737ed00 Polish "Update links in reference manual"
See gh-33245
2024-07-20 11:51:49 +02:00
Tran Ngoc Nhan 61d1fde797 Update links in reference manual
See gh-33245
2024-07-20 11:32:35 +02:00
Brian Clozel b701b26b07 Merge branch '6.1.x' 2024-07-19 17:23:14 +02:00
Brian Clozel 0bb309f433 Instrument @JmsListener session for response messages
Prior to this commit, the observation instrumentation for `@JmsListener`
annotated methods (implemented in `AbstractMessageListenerContainer`
would not instrument the JMS session using the Micrometer JMS support.
This means that response messages returned from the listener method
would be sent but no observation would be recorded. As a result, tracing
message properties would be also missing.

This commit ensures that the session provided to the listener method is
instrumented beforehand, if Micrometer is on the classpath and an
observation registry has been configured.

Fixes gh-33221
2024-07-19 17:17:18 +02:00
rstoyanchev 93d5be621b Merge branch '6.1.x' 2024-07-10 17:55:48 +01:00
rstoyanchev 611d3e5551 Correct type names in docs on Validation in WebFlux
Closes gh-33061
2024-07-10 17:55:19 +01:00
rstoyanchev b93b7e013a Add FragmentsRendering to documentation for return values
Closes gh-33162
2024-07-10 16:50:12 +01:00
Juergen Hoeller a9efe10428 Merge branch '6.1.x'
# Conflicts:
#	spring-beans/src/main/java/org/springframework/beans/factory/aot/DefaultBeanRegistrationCodeFragments.java
2024-07-10 15:16:40 +02:00
Juergen Hoeller 300f4585be Update spring.jdbc.getParameterType.ignore note for 6.1.2
See gh-25679
2024-07-10 15:15:26 +02:00
Stéphane Nicoll b7ec028149 Merge branch '6.1.x' 2024-07-08 16:52:01 +02:00
Hunhee Lee 3d8f1fb00f Harmonize phrasing in URI Encoding section
See gh-33166
2024-07-08 16:51:09 +02:00
Stéphane Nicoll 93587da394 Introduce ReflectiveScan
This commit allows `@Reflective` to be used on arbitrary types, not
only Spring beans. This makes the feature much more powerful as
components can be tagged directly.

Scanning happens during AOT processing (typically at build-time) when
`@ReflectiveScan` is used. Types do not need to have a particular
annotation, and types that can't be loaded are ignored.

This commit also exposes the infrastructure that does the scanning so
that custom code can do the scanning in an AOT contribution if they
don't want to rely on the annotation.

Closes gh-33132
2024-07-08 11:11:48 +02:00
Stéphane Nicoll f1658079a5 Polish documentation for RegisterReflection
See gh-29194
2024-07-06 09:31:12 +02:00
Sam Brannen abcad5dbcf Support property placeholders in @⁠Sql script paths
Prior to this commit, paths configured via the scripts attribute in
@⁠Sql were required to be final paths without dynamic placeholders;
however, being able to make script paths dependent on the current
environment can be useful in certain testing scenarios.

This commit introduces support for property placeholders (${...}) in
@⁠Sql script paths which will be replaced by properties available in
the Environment of the test's ApplicationContext.

Closes gh-33114
2024-07-03 17:16:53 +02:00
Sam Brannen a8e8897a00 Stop referring to old Spring versions in the reference manual 2024-07-01 18:37:46 +02:00
Sam Brannen e02cddd155 Delete obsolete documentation for JNDI mock support 2024-07-01 18:32:28 +02:00
Sam Brannen e427ac2683 Document parallel execution regarding @⁠MockitoBean & @⁠MockitoSpyBean 2024-07-01 17:08:09 +02:00
Sam Brannen 56fe857f1e Don't reference "Spring Framework 5.0" in parallel test execution section 2024-07-01 17:03:43 +02:00
Sam Brannen cc002875c4 Support fully-qualified factory method names in @⁠TestBean
Prior to this commit, @⁠TestBean factory methods had to be defined in
the test class, one of its superclasses, or in an implemented
interface. However, users may wish to define common factory methods in
external classes that can be shared easily across multiple test classes
simply by referencing an external method via a fully-qualified method
name.

To address that, this commit introduces support for referencing a
@⁠TestBean factory method via its fully-qualified method name following
the syntax <fully-qualified class name>#<method name>.

Closes gh-33125
2024-06-30 21:16:04 +02:00
Sam Brannen b64edb2d2a Update Content-Type based on encoding in MVC FreeMarkerView
Closes gh-33119
2024-06-29 17:12:48 +02:00
Sam Brannen e1567b93c2 Merge branch '6.1.x' 2024-06-27 11:40:16 +02:00
Sam Brannen 8b11ee9ee2 Document that ModelMap is not a supported argument type in WebFlux
Prior to this commit, the "Method Arguments" documentation for WebFlux
in the reference manual stated that WebFlux controller methods can
accept arguments of type Map, Model, or ModelMap to access the model.
However, ModelMap is actually not supported and results in exception
due to a type mismatch.

This commit updates the documentation to reflect this.

In addition, this commit updates related Javadoc and tests to avoid
mentioning or using ModelMap in WebFlux.

Closes gh-33107
2024-06-27 11:33:50 +02:00
Sam Brannen 1cf5264163 Polishing 2024-06-27 10:46:00 +02:00
Sam Brannen 08112963a2 Merge branch '6.1.x' 2024-06-26 16:45:34 +02:00
Sam Brannen c68c6faa03 Fix comment in Method Injection example in reference manual
Prior to this commit, the comment in the XML configuration example in
the Method Injection section of the reference manual referred to the
wrong bean names.

Closes gh-33096
2024-06-26 16:45:06 +02:00
Juergen Hoeller d9a2e0b731 Merge branch '6.1.x' 2024-06-24 12:27:23 +02:00
rstoyanchev 6e82bf05b6 Document list/map/array constructor data binding
Closes gh-32426
2024-06-24 11:25:22 +01:00
Juergen Hoeller 4e2fb308f6 Document contentLength() behavior for InputStreamResource and custom subclasses
Closes gh-33089
2024-06-24 12:10:35 +02:00
Stéphane Nicoll b134f253b5 Move the testing section after data and web
Closes gh-33083
2024-06-21 14:35:33 +02:00
Stéphane Nicoll d43dba63a1 Document AssertJ support for MockMvc
This commit restructures the section on MockMvc so that the anchors
are easier to read. The standard integration has moved to a
Hamcrest Integration section  at the same level as HtmlUnit Integration,
and a new AssertJ Integration section has been created.

Closes gh-32454
2024-06-21 12:51:35 +02:00
Brian Clozel 4cbaaa3b1d Move Servlet HTTP Message Conversion to its own section
Closes gh-33063
2024-06-19 15:45:16 +02:00
Stéphane Nicoll e4c881be73 Merge branch '6.1.x' 2024-06-17 13:43:23 +02:00
Stéphane Nicoll 3e0849a566 Fix typo
Closes gh-33050
2024-06-17 13:39:18 +02:00
Stéphane Nicoll 5edb4cb2c9 Merge branch '6.1.x' 2024-06-16 16:51:15 +02:00
Stéphane Nicoll 6fdff201e9 Fix property name in Container Extension Points section
Closes gh-33037
2024-06-16 16:47:36 +02:00
Stéphane Nicoll 2d48371c6d Revert polish on Bean Override support
This commit revers the removal of the `private` keyword in the examples
of the reference documentation and the tests for consistency. While the
default visibility makes the example more concise, it could imply to the
reader that the field (or the factory method) cannot be private.

Also, there is no need to multiply anything returned from `Objects.hash`
as its very distinct on its own already.
2024-06-12 08:11:18 +02:00
Sam Brannen f481a4b60b Polish reference documentation 2024-06-11 16:31:56 +02:00
Arjen Poutsma 60b5bbe334 Introduce request attributes in RestClient
This commit introduces request attributes in the RestClient and
underlying infrastructure (i.e. HttpRequest).

Closes gh-32027
2024-06-11 15:51:29 +02:00
Stéphane Nicoll 28f62abda4 Use the field name as a fallback qualifier for Bean Overriding
This commit harmonizes how a candidate bean definition is determined
for overriding using `@TestBean`, `@MockitoBean`, and `@MockitoSpyBean`.

Previously, a qualifier was necessary even if the name of the annotated
field matches the name of a candidate. After this commit, such candidate
will be picked up transparently, the same it is done for regular
autowiring.

This commit also reviews the documentation of the feature as considering
the field means that its name is taken into account to compute a cache
key if by-type lookup is requested.

Closes gh-32939
2024-06-11 11:30:01 +02:00
Juergen Hoeller eca2b9657e Documentation notes for @Bean overriding and bean name matching
Closes gh-32825
2024-06-11 09:06:33 +02:00
Juergen Hoeller 42c17eb787 Documentation notes for @Bean overriding and bean name matching
See gh-31052
See gh-28122
2024-06-10 16:43:05 +02:00
Stéphane Nicoll 96302a7102 Stop using a conventional suffix for TestBean factory methods
This commit changes how factory method for `@TestBean` usage is
discovered. Previously the field name or bean name suffixed with
'TestOverride' was used. It sounds more natural to just use the
field name or bean name, leaving cases where a suffix is required
to explicitly providing the method name.

As part of this change, the exception messages have been revisited as
it's less since the method name candidates have the exact same name
as the field or bean name. A `()` is added to make it more clear the
name is for a method.

Closes gh-32940
2024-06-10 12:52:21 +02:00
Stéphane Nicoll b7e4fa06c3 Merge branch '6.1.x' 2024-06-10 10:02:41 +02:00
hlmg c6c64e6fe7 Fix typo
See gh-32993
2024-06-10 10:00:37 +02:00
Sébastien Deleuze 20d23584f6 Merge branch '6.1.x' 2024-06-07 13:45:19 +02:00
Sébastien Deleuze 43a113f067 Polishing
See gh-32983
2024-06-07 13:45:09 +02:00
Sébastien Deleuze 8073f32ca6 Merge branch '6.1.x' 2024-06-07 13:36:39 +02:00
Sébastien Deleuze dc250e1cc1 Remove outdated copyright from index.adoc
Closes gh-32983
2024-06-07 13:35:21 +02:00
Sébastien Deleuze 7b9cbd7876 Add support for Kotlin BeanPostProcessor beans
This commit adds support for Kotlin BeanPostProcessor beans which should
be defined in a companion object and annotated with `@JvmStatic`.

Closes gh-32946
2024-06-06 19:23:25 +02:00
Stéphane Nicoll 5706ee1762 Merge branch '6.1.x' 2024-06-06 08:08:47 +02:00
ypyf e12d1259d1 Use HttpStatusCode consistently in reference guide
See gh-32966
2024-06-06 08:06:33 +02:00
rstoyanchev f4f89aa2a4 Add headers to data binding values
Closes gh-32676
2024-06-05 11:30:32 +01:00
Stéphane Nicoll 36b0702c0b Merge branch '6.1.x' 2024-06-05 10:45:06 +02:00
Tony Wen 301087e510 Fix entity name in MappingSqlQuery example of reference guide
See gh-32957
2024-06-05 10:43:14 +02:00
Stéphane Nicoll 5cd4b87bfa Merge branch '6.1.x' 2024-06-04 15:52:26 +02:00
Stéphane Nicoll 7102c33661 Add section about using complex data structures with AOT
Closes gh-32273
2024-06-04 15:51:40 +02:00
Sébastien Deleuze eefdf42e7e Merge branch '6.1.x' 2024-06-03 18:28:17 +02:00
Sébastien Deleuze 31806f3a6b Fix MethodValidationPostProcessor refdoc
Closes gh-32929
2024-06-03 18:20:52 +02:00
Sam Brannen 967800a2f9 Merge branch '6.1.x' 2024-05-31 12:23:22 +02:00
Cong-Xin Cynthia Qiu 542ba3517f Fix typo in Jakarta validation documentation
Closes gh-32928
2024-05-31 12:22:02 +02:00
Sam Brannen 7e3a4a12f8 Use consistent version strings for 6.2 2024-05-24 15:19:30 +02:00
Sam Brannen e3c268ef18 Fix formatting 2024-05-24 13:39:55 +02:00
Sébastien Deleuze f62275d674 Merge branch '6.1.x' 2024-05-23 16:05:54 +02:00
Attacktive 73eb6f0660 Complete a Kotlin code snippet in the refdoc
Closes gh-32877
2024-05-23 16:03:34 +02:00
Stéphane Nicoll 181b68088a Merge branch '6.1.x' 2024-05-23 08:14:59 +02:00
Stéphane Nicoll c01aab5850 Polish
See gh-32874
2024-05-23 08:12:30 +02:00
Seungrae 61ef5a8930 Document using ThreadLocal#remove instead of ThreadLocal#set(null)
See gh-32874
2024-05-23 08:10:54 +02:00
rstoyanchev 89dd247b97 Improve docs on controller method validation
Closes gh-32807
2024-05-22 17:15:54 +01:00
rstoyanchev 1ddc84862e Improve docs on controller method validation
Closes gh-32807
2024-05-22 17:12:09 +01:00
Simon Baslé d5c7a5e2db Bean overriding by type uses isAutowireCandidate for matching
This commit uses the bean factory `isAutowiredCandidate` method directly
in `BeanOverrideBeanFactoryPostProcessor` to select a single match among
multiple candidates when matching by type.

The expected consequence, in most cases, is that this will delegate to
a `@Qualifier`-aware `QualifierAnnotationAutowireCandidateResolver`.
In that sense, bean overriding by-type matching is now potentially
taking Qualifier annotations or meta-annotations into account.

It also changes the way existing bean definitions are checked in case
a bean name has been specified: factory beans are now taken into account
when checking the type of an existing definition matches the expected
bean override type.

Closes gh-32822
2024-05-21 14:06:52 +02:00
Brian Clozel 4d4b343815 Support Content Negotiation with @ExceptionHandler
Prior to this commit, `@ExceptionHandler` annotated controller methods
could be mapped using the exception type declaration as an annotation
attribute, or as a method parameter.
While such methods support a wide variety of method arguments and return
types, it was not possible to declare the same exception type on
different methods (in the same controller/controller advice).

This commit adds a new `produces` attribute on `@ExceptionHandler`; with
that, applications can vary the HTTP response depending on the exception
type and the requested content-type by the client:

```
@ExceptionHandler(produces = "application/json")
public ResponseEntity<ErrorMessage> handleJson(IllegalArgumentException exc) {
	return ResponseEntity.badRequest().body(new ErrorMessage(exc.getMessage(), 42));
}

@ExceptionHandler(produces = "text/html")
public String handle(IllegalArgumentException exc, Model model) {
	model.addAttribute("error", new ErrorMessage(exc.getMessage(), 42));
	return "errorView";
}
```

This commit implements support in both Spring MVC and Spring WebFlux.

Closes gh-31936
2024-05-20 17:22:30 +02:00
Sébastien Deleuze 268043a28c Merge branch '6.1.x' 2024-05-20 10:24:42 +02:00
Sébastien Deleuze 2a2ef443a5 Refine CDS documentation
Closes gh-32843
2024-05-20 10:24:29 +02:00
SharadK10 a3b62a80bc
Improve wording in Spring Framework Overview documentation
Closes gh-32829
2024-05-15 19:00:27 +02:00
Sam Brannen 6cdb34410b Register DynamicPropertyRegistry as singleton bean in test ApplicationContext
Prior to this commit, DynamicPropertyRegistry could only be used with a
static @⁠DynamicPropertySource method in an integration test class;
however, it can also be useful to be able to register a "dynamic
property" from within a test's ApplicationContext -- for example, in a
@⁠Bean method in a @⁠Configuration class that is specific to testing
scenarios.

To support such use cases, this commit updates the dynamic property
source infrastructure so that a DynamicPropertyRegistry is always
registered as a singleton bean in a test's ApplicationContext. This
allows DynamicPropertyRegistry to be autowired into a @⁠Configuration
class or supplied to a @⁠Bean method as an argument as shown in the
following example.

@⁠Bean
@⁠DynamicPropertySource
ApiServer apiServer(DynamicPropertyRegistry registry) {
	ApiServer apiServer = new ApiServer();
	registry.add("api.url", apiServer::getUrl);
	return apiServer;
}

Note that the use of @⁠DynamicPropertySource on the @⁠Bean method is
optional and results in the corresponding bean being eagerly
initialized so that other singleton beans in the context can be given
access to the dynamic properties sourced from that bean when those
other beans are initialized.

Side note: DynamicPropertySourceBeanInitializer temporarily implements
LoadTimeWeaverAware since doing so is currently the only way to have a
component eagerly initialized before the
ConfigurableListableBeanFactory.preInstantiateSingletons() phase.
However, we plan to introduce a first-class callback to support such
use cases in the future.

Closes gh-32271
2024-05-15 17:09:03 +02:00
Sam Brannen d625b3de27 Document SpEL IndexAccessor support in the reference manual
Closes gh-32735
2024-05-15 11:47:42 +02:00
Juergen Hoeller 7c534eeeeb Merge branch '6.1.x'
# Conflicts:
#	framework-platform/framework-platform.gradle
2024-05-14 22:02:32 +02:00
Juergen Hoeller e509385eae Add InputStreamResource(InputStreamSource) constructor for lambda expressions
Includes notes for reliable InputStream closing, in particular with Spring MVC.

Closes gh-32802
2024-05-14 21:59:42 +02:00
Simon Baslé a86612a254 Use by-type semantics in bean overriding if no explicit name is provided
This change switches default behavior of `@TestBean`, `@MockitoBean` and
`@MockitoSpyBean` to match the bean definition / bean to override by
type in the case there is no explicit bean name provided via the
annotation. The previous behavior of using the annotated field's name
is still an option for implementors, but no longer the default.

Closes gh-32761
2024-05-14 16:42:11 +02:00
Brian Clozel 80ec951fcf Merge branch '6.1.x' 2024-05-13 13:15:01 +02:00