Exception for resolving a graph with unsatisfied dependencies

16 views
Skip to first unread message

Ervin Nagy

unread,
Apr 5, 2025, 7:14:49 AMApr 5
to Spring4D
Is it possible to raise an exception at Resolve if some dependencies are not registered?

Stefan Glienke

unread,
Apr 5, 2025, 7:18:34 AMApr 5
to Spring4D
It already does - the case you probably face is that it falls back to another ctor that it can satisfy - often that is the default ctor.

If you don't want the container to fall back to a ctor of a base class then add the extension from Spring.Container.ActivatorExtension.pas to the container. This changes the way the container looks for eligible ctors.
The second way you can force a ctor to be taken is to annotate it with the [Inject] attribute. Then the container will look no further and raises if it cannot satisfy all its parameters.


Reply all
Reply to author
Forward
0 new messages