UnsatisfiedDependencyException class

The error thrown when an injection point of a bean cannot be filled: the bean, its injection point and the reason are in the message.

This is the usual startup error of a misconfigured application; it is a BeanCreationException. It is thrown by validateBeanGraph (a declared dependency has no bean or several candidates, a required @Value placeholder has no value) and when resolving an injection point fails while the bean is created: cause is the lookup error (a missing or ambiguous bean, or the failure of the dependency's own creation), so nested exceptions show the chain of beans and injection points.

// The `${smtp}` property is missing from the configuration.
try {
  context.refresh();
} on UnsatisfiedDependencyException catch (e) {
  log.error('${e.beanName}: ${e.dependency}'); // mailer: @Value("${smtp}")
}

Spring (Java):

try {
  context.refresh();
} catch (UnsatisfiedDependencyException e) {
  log.error(e.getBeanName() + ": " + e.getInjectionPoint());
}
Inheritance

Constructors

UnsatisfiedDependencyException(String beanName, String dependency, String reason, {Object? cause, StackTrace? causeStackTrace})
The injection point dependency of beanName failed for reason.

Properties

beanName → String
The bean whose creation failed.
finalinherited
cause → Object?
The error that caused this one, if any: what a constructor threw, or the container error of a nested bean.
finalinherited
causeStackTrace → StackTrace
The stack trace of cause (empty without a cause).
finalinherited
dependency → String
A description of the failed injection point (e.g. @Value("${port}") or Greeter 'delegate').
final
hashCode → int
The hash code for this object.
no setterinherited
message → String
A human-readable description of the problem.
finalinherited
mostSpecificCause → Object
rootCause, or this exception when it has no cause. Spring: getMostSpecificCause().
no setterinherited
rootCause → Object?
The innermost cause: cause followed through nested container errors, or null without a cause. Usually the error that really went wrong. Spring: getRootCause().
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited