defining a CommandTargetResolver in springboot with AutoConfiguration

Hi,

Can anyone share the magic recipe how to define a commandtargetresolver when using the spring-boot-starter with autoconfiguration ? The documentation just says we can supply a custom commandtargetresolver but doesn’t say how :confused: I know Axon quite well but to be honest having the declarative xml configuration in Axon2 was much easier to manage and understand than declaring random things left and right to adjust behaviour up or down (but this is more a general autoconfiguration remark, nothing to do with Axon just ranting :wink:

Thanks,
Jorg

The magic recipe so that others don’t have to go through the same experience:

`

@Bean
public AggregateConfigurer configure() {
return AggregateConfigurer.defaultConfiguration(MyAR.class)
.configureCommandTargetResolver(…);
}

`

Jorg

Hi Jorg,

Sorry for not coming back to you quick enough.
Great that you found it though, that currently is the approach to set a CommandTargetResolver.
As of Axon 3.3, this issue (which you created, thanks for that), should give you a simpler solution to setting the CommandTargetResolver for your Aggregates.

When in an Axon 3.3 space, you will be able to set the commandTargetResolver on the @Aggregate annotation.

Axon will then internally check if it can find a bean with the name specified in your annotation.
That will thus allow you to just create a bean creator function for your CommandTargetResolver which will be wired to that specific Aggregate.

A Default CommandTargerResolver will also be configurable, although that issue is still in progress.

Cheers,
Steven

No problem Steven, appreciate the heads-up on this.

Jorg