Merge branch '5.1.x'

This commit is contained in:
Juergen Hoeller 2019-04-04 16:12:07 +02:00
commit 1741b6dcd9
5 changed files with 43 additions and 23 deletions

View File

@ -72,7 +72,7 @@ dependencies {
testCompile("org.apache.tiles:tiles-core:${tiles3Version}", withoutJclOverSlf4J) testCompile("org.apache.tiles:tiles-core:${tiles3Version}", withoutJclOverSlf4J)
testCompile("org.apache.tiles:tiles-servlet:${tiles3Version}", withoutJclOverSlf4J) testCompile("org.apache.tiles:tiles-servlet:${tiles3Version}", withoutJclOverSlf4J)
testCompile("org.hsqldb:hsqldb:${hsqldbVersion}") testCompile("org.hsqldb:hsqldb:${hsqldbVersion}")
testCompile("org.apache.httpcomponents:httpclient:4.5.7") { testCompile("org.apache.httpcomponents:httpclient:4.5.8") {
exclude group: "commons-logging", module: "commons-logging" exclude group: "commons-logging", module: "commons-logging"
} }
testCompile("io.projectreactor.netty:reactor-netty") testCompile("io.projectreactor.netty:reactor-netty")

View File

@ -37,9 +37,9 @@ dependencies {
optional("org.eclipse.jetty:jetty-servlet") { optional("org.eclipse.jetty:jetty-servlet") {
exclude group: "javax.servlet", module: "javax.servlet-api" exclude group: "javax.servlet", module: "javax.servlet-api"
} }
optional("org.eclipse.jetty:jetty-reactive-httpclient:1.0.2") optional("org.eclipse.jetty:jetty-reactive-httpclient:1.0.3")
optional("com.squareup.okhttp3:okhttp:3.14.0") optional("com.squareup.okhttp3:okhttp:3.14.0")
optional("org.apache.httpcomponents:httpclient:4.5.7") { optional("org.apache.httpcomponents:httpclient:4.5.8") {
exclude group: "commons-logging", module: "commons-logging" exclude group: "commons-logging", module: "commons-logging"
} }
optional("org.apache.httpcomponents:httpasyncclient:4.1.4") { optional("org.apache.httpcomponents:httpasyncclient:4.1.4") {

View File

@ -35,7 +35,7 @@ dependencies {
optional("io.undertow:undertow-websockets-jsr:${undertowVersion}") { optional("io.undertow:undertow-websockets-jsr:${undertowVersion}") {
exclude group: "org.jboss.spec.javax.websocket", module: "jboss-websocket-api_1.1_spec" exclude group: "org.jboss.spec.javax.websocket", module: "jboss-websocket-api_1.1_spec"
} }
optional("org.apache.httpcomponents:httpclient:4.5.7") { optional("org.apache.httpcomponents:httpclient:4.5.8") {
exclude group: "commons-logging", module: "commons-logging" exclude group: "commons-logging", module: "commons-logging"
} }
optional("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}") optional("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")
@ -53,7 +53,7 @@ dependencies {
testCompile("org.apache.tomcat:tomcat-util:${tomcatVersion}") testCompile("org.apache.tomcat:tomcat-util:${tomcatVersion}")
testCompile("org.eclipse.jetty:jetty-server") testCompile("org.eclipse.jetty:jetty-server")
testCompile("org.eclipse.jetty:jetty-servlet") testCompile("org.eclipse.jetty:jetty-servlet")
testCompile("org.eclipse.jetty:jetty-reactive-httpclient:1.0.2") testCompile("org.eclipse.jetty:jetty-reactive-httpclient:1.0.3")
testCompile("com.squareup.okhttp3:mockwebserver:3.14.0") testCompile("com.squareup.okhttp3:mockwebserver:3.14.0")
testCompile("org.jetbrains.kotlin:kotlin-script-runtime:${kotlinVersion}") testCompile("org.jetbrains.kotlin:kotlin-script-runtime:${kotlinVersion}")
testCompile(project(":spring-core-coroutines")) testCompile(project(":spring-core-coroutines"))

View File

@ -50,7 +50,7 @@ dependencies {
testCompile("org.eclipse.jetty:jetty-server") { testCompile("org.eclipse.jetty:jetty-server") {
exclude group: "javax.servlet", module: "javax.servlet" exclude group: "javax.servlet", module: "javax.servlet"
} }
testCompile("org.apache.httpcomponents:httpclient:4.5.7") { testCompile("org.apache.httpcomponents:httpclient:4.5.8") {
exclude group: "commons-logging", module: "commons-logging" exclude group: "commons-logging", module: "commons-logging"
} }
testCompile("commons-fileupload:commons-fileupload:1.4") testCompile("commons-fileupload:commons-fileupload:1.4")

View File

@ -4425,9 +4425,9 @@ implementation type, consider declaring the most specific return type on your fa
method (at least as specific as required by the injection points referring to your bean). method (at least as specific as required by the injection points referring to your bean).
==== ====
You can also provide all beans of a particular type from the You can also provide all beans of a particular type from the `ApplicationContext`
`ApplicationContext` by adding the annotation to a field or method that expects an array by adding the annotation to a field or method that expects an array of that type,
of that type, as the following example shows: as the following example shows:
[source,java,indent=0] [source,java,indent=0]
[subs="verbatim,quotes"] [subs="verbatim,quotes"]
@ -4477,8 +4477,8 @@ Note that the standard `javax.annotation.Priority` annotation is not available a
through `@Order` values in combination with `@Primary` on a single bean for each type. through `@Order` values in combination with `@Primary` on a single bean for each type.
==== ====
Even typed `Map` instances can be autowired as long as the expected key type is `String`. The Map Even typed `Map` instances can be autowired as long as the expected key type is `String`.
values contain all beans of the expected type, and the keys contain the The Map values contain all beans of the expected type, and the keys contain the
corresponding bean names, as the following example shows: corresponding bean names, as the following example shows:
[source,java,indent=0] [source,java,indent=0]
@ -4497,10 +4497,14 @@ corresponding bean names, as the following example shows:
} }
---- ----
By default, the autowiring fails whenever zero candidate beans are available. The By default, autowiring fails when no matching candidate beans are available for
default behavior is to treat annotated methods, constructors, and fields as a given injection point. In the case of a declared array, collection or map,
indicating required dependencies. You can change this behavior as demonstrated, in the at least one matching element is expected.
following example:
The default behavior is to treat annotated methods and fields as indicating
required dependencies. You can change this behavior as demonstrated in the
following example, enabling the framework to skip a non-satisfiable injection
point through marking it as non-required:
[source,java,indent=0] [source,java,indent=0]
[subs="verbatim,quotes"] [subs="verbatim,quotes"]
@ -4518,18 +4522,34 @@ following example:
} }
---- ----
A non-required method will not be called at all if its dependency (or one of its
dependencies in case of multiple arguments) is not available. A non-required field
will not get populated at all in such case, leaving its default value in place.
Injected constructor and factory method arguments are a special case since the
'required' flag on `@Autowired` has a somewhat different meaning due to Spring's
constructor resolution algorithm potentially dealing with multiple constructors.
Constructor and factory method arguments are effectively required by default but
with a few special rules in a single-constructor scenario, such as multi-element
injection points (arrays, collections, maps) resolving to empty instances if no
matching beans are available. This allows for a common implementation pattern
where all dependencies can be declared in a unique multi-argument constructor,
e.g. declared as a single public constructor without an `@Autowired` annotation.
[NOTE] [NOTE]
==== ====
Only one annotated constructor per-class can be marked as required, but multiple Only one annotated constructor per class can be marked as required, but multiple
non-required constructors can be annotated. In that case, each is considered among the non-required constructors can be annotated. In that case, each is considered among
candidates and Spring uses the greediest constructor whose dependencies can be the candidates and Spring uses the greediest constructor whose dependencies can be
satisfied -- that is, the constructor that has the largest number of arguments. satisfied -- that is, the constructor that has the largest number of arguments.
The constructor resolution algorithm is the same as for non-annotated classes with
overloaded constructors, just narrowing the candidates to annotated constructors.
The required attribute of `@Autowired` is recommended over the `@Required` annotation. The 'required' attribute of `@Autowired` is recommended over the `@Required` annotation
The required attribute indicates that the property is not required for autowiring on setter methods. The 'required' attribute indicates that the property is not required
purposes. The property is ignored if it cannot be autowired. `@Required`, on the other for autowiring purposes. The property is ignored if it cannot be autowired. `@Required`,
hand, is stronger in that it enforces the property that was set by any means supported on the other hand, is stronger in that it enforces the property to be set by any means
by the container. If no value is injected, a corresponding exception is raised. supported by the container. If no value is defined, a corresponding exception is raised.
==== ====
Alternatively, you can express the non-required nature of a particular dependency Alternatively, you can express the non-required nature of a particular dependency