Support @Nullable annotations as indicators for optional injection points [SPR-15028] #19595
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
Milestone
Juergen Hoeller opened SPR-15028 and commented
Along the lines of Guice (https://github.com/google/guice/wiki/UseNullable), we can easily detect
@Nullable
annotations and automatically mark method parameters and dependency descriptors as optional, i.e. not required, injectingnull
instead of throwing anUnsatisfiedDependencyException
. This is particularly useful with JSR-330's@Inject
where not@Autowired
-stylerequired
attribute is available at the injection annotation level, as an alternative to using Java 8'sjava.util.Optional
(which Spring supports for a while already). This also nicely goes along with our support for nullable type declarations in Kotlin.Issue Links:
@Autowired
and@Inject
@Inject
(a la@Autowired
's required=false)Referenced from: commits 12aa14d
The text was updated successfully, but these errors were encountered: