Hi,
I was wondering if it is possible to autowire a spring bean (non-boot) into a @CommandHandler method of an aggregate. I’ve seen that it is possible with
@EventSourcingHandler, but can’t seem to get it to work on a commandHandler method.
Kind regards,
David
Sure,
All you need is a SpringParameterResolverFactoryBean In your spring context.
Rgds,
Benoît
I solved it by injecting the ParameterResolverFactory
into my AggregateRepository.
Part of my issue was that the @CommandHandler with the autowiring bean was on the constructor of my aggregate, so it is required when the Aggregate repository is instantiated.
Now is the case tjat I configure the bean for the aggregate repository myself, so it didn’t have the ParameterResolverFactory.
Fixed.
Thank you
Kind regards,
David Stibbe
I’m having this same issue and I’m not sure if I follow.
How do I create a SpringParameterResolverFactoryBean so I can autowire objects within my aggregate?
Any autowire that I currently do returns a null value
I was able to resolve my issue by autowiring directly into the handler function.
Using a non-spring-boot config?
What did your config look like?