NotConstructorBoundInjectionFailureAnalyzer Class — spring-boot Architecture
Architecture documentation for the NotConstructorBoundInjectionFailureAnalyzer class in NotConstructorBoundInjectionFailureAnalyzer.java from the spring-boot codebase.
Entity Profile
Relationship Graph
Source Code
core/spring-boot/src/main/java/org/springframework/boot/context/properties/NotConstructorBoundInjectionFailureAnalyzer.java lines 42–89
class NotConstructorBoundInjectionFailureAnalyzer
extends AbstractInjectionFailureAnalyzer<NoSuchBeanDefinitionException> implements Ordered {
@Override
public int getOrder() {
return 0;
}
@Override
protected @Nullable FailureAnalysis analyze(Throwable rootFailure, NoSuchBeanDefinitionException cause,
@Nullable String description) {
InjectionPoint injectionPoint = findInjectionPoint(rootFailure);
if (isConstructorBindingConfigurationProperties(injectionPoint)) {
String simpleName = injectionPoint.getMember().getDeclaringClass().getSimpleName();
String action = "Update your configuration so that " + simpleName + " is defined via @"
+ ConfigurationPropertiesScan.class.getSimpleName() + " or @"
+ EnableConfigurationProperties.class.getSimpleName() + ".";
return new FailureAnalysis(
simpleName + " is annotated with @" + ConstructorBinding.class.getSimpleName()
+ " but it is defined as a regular bean which caused dependency injection to fail.",
action, cause);
}
return null;
}
@Contract("null -> false")
private boolean isConstructorBindingConfigurationProperties(@Nullable InjectionPoint injectionPoint) {
return injectionPoint != null && injectionPoint.getMember() instanceof Constructor<?> constructor
&& isConstructorBindingConfigurationProperties(constructor);
}
private boolean isConstructorBindingConfigurationProperties(Constructor<?> constructor) {
Class<?> declaringClass = constructor.getDeclaringClass();
BindMethod bindMethod = ConfigurationPropertiesBean.deduceBindMethod(declaringClass);
return MergedAnnotations.from(declaringClass, SearchStrategy.TYPE_HIERARCHY)
.isPresent(ConfigurationProperties.class) && bindMethod == BindMethod.VALUE_OBJECT;
}
private @Nullable InjectionPoint findInjectionPoint(Throwable failure) {
UnsatisfiedDependencyException unsatisfiedDependencyException = findCause(failure,
UnsatisfiedDependencyException.class);
if (unsatisfiedDependencyException == null) {
return null;
}
return unsatisfiedDependencyException.getInjectionPoint();
}
}
Domain
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free