Inject Spring bean in command handler axon 4.03+Spring boot

I’m trying to configure parameter resolver in order to inject spring bean service in command handler as Allard mentioned here :

You may have to register the ParameterResolver with the configurer as a component:

MultiParameterResolverFactory.ordered(ClasspathParameterResolverFactory.forClass(getClass()), new ConfigurationParameterResolverFactory(config),
/* add your own here */)
But I don’t understand how to do it with Spring boot , I have tried (already sent in picture)

But I get the method registerComponent(Class, Function<Configuration,? extends C>) in the type Configurer is not applicable for the arguments (Class, MultiParameterResolverFactory).
I will be very glad if someone can help me to resolve this issue.


Hi Nouha,

when using Spring Boot, the only thing you need to do to register an additional ParameterResolver is to just define it as a bean. The Axon Spring Boot Autoconfiguration module will pick it up automatically.

If you want to take the approach where you register it with the Configurer, the way to do that in Spring Boot is:

// in an @Configuration class

public void configure(Configurer configurer) {
configurer.registerComponent(ParameterResolverFactory.class, c -> … create parameter resolver factory);

The latter requires you to configure the ParameterResolverFactory that is valid for all parameter types you need to support. Therefore, defining them as a Spring bean is the preferred method.

Hope this helps.

Thank You Allard.