Add a `FailureAnalyzer` that handles the case where the context does
not start because no candidate bean was found for an `InjectionPoint`.
The implementation inspects the auto-configuration report for beans
that are candidate and output the condition(s) that lead to such beans
to be discarded on startup. If a whole auto-configuration class is
disabled (or excluded), its beans are inspected and candidates are
extracted in a similar way.
This works for both injection by type and by name.
Closes gh-6612
This works, and feels like the right thing to do, since there is no
guarantee that extensions won't in turn use ServiceLoader for things
that we haven't yet anticipated.
Fixes gh-6829. Cc @wilkinsona in case he has an opinion.
Post-processing of mocked beans causes a number of problems:
- The mock may be proxied for asynchronous processing which can cause
problems when configuring expectations on a mock (gh-6573)
- The mock may be proxied so that its return values can be cached or
so that its methods can be transactional. This causes problems with
verification of the expected calls to a mock (gh-6573, gh-5837)
- If the mock is created from a class that uses field injection, the
container will attempt to inject values into its fields. This causes
problems if the mock is being created to avoid the use of one of
those dependencies (gh-6663)
- Proxying a mocked bean can lead to a JDK proxy being created
(if proxyTargetClass=false) as the mock implements a Mockito
interface. This can then cause injection failures as the types don’t
match (gh-6405, gh-6665)
All of these problems can be avoided if a mocked bean is not
post-processed. Avoiding post-processing prevents proxies from being
created and autowiring from being performed. This commit avoids
post-processing by registering mocked beans as singletons as well as
via a bean definition. The latter is still used by the context for type
matching purposes.
Closes gh-6573, gh-6663, gh-6664
This commit adds `JdbcTemplateAutoConfiguration` to the list of auto-
configurations that are applied with `DataJpaTest`. This effectively
allows to inject a `JdbcTemplate` in any `@DataJpaTest` test.
Closes gh-6802
Rework commit 4a69755b to remove the need for the ApplicationInfo class.
The updated code now uses the auto-configuration class to compute a
default persistence unit root location
Closes gh-6635
Previously, the HAL browser endpoint did not consider the dispatcher
servlet’s path (server.servlet-path) when redirecting to browser.html
or when updating the API entry point in the served HTML.
This commit moves to using ServletUriComponentsBuilder to build the URI
for the redirect and the path for the entry point. In the interests of
simplicity the logic that sometimes redirected and sometimes forwarded
the request has been changed so that it will always perform a redirect.
Closes gh-6586
This commit improves the run goal to automatically fork the process when
devtools is present and log a warning when fork has been disabled via
configuration since devtools will not work on a non-forked process.
We don't want devtools to kick in for integration tests so the logic has
been placed in `RunMojo` requiring a couple of protected methods to
override.
Closes gh-5137
Update @MockBean and @SpyBean to support field generics. Prior to this
commit the following fields would fail with a "Duplicate mock
definition" exception:
@MockBean
private IdentityProvider<PasswordIdentity> passwordIdentityProvider;
@MockBean
private IdentityProvider<Oauth2Identity> oauth2IdentityProvider;
Fixes gh-6602