Hi,
within axon 2.x I was creating command handlers as spring’s @Component. Now in axon 3.x this doesn’t work anymore.
What is the minimal configuration needed to register command handler with it’s repository?
I was trying this:
@Aggregate
public class AccessorAggregateRoot implements Serializable {
private static final long serialVersionUID = -6507215786865192829L;
@AggregateIdentifier
private AccessorId accessorId;
...
}
@Configuration
public class AccessorCommandConfiguration {
@Bean
Repository<AccessorAggregateRoot> accessorAggregateRootRepository(AxonConfiguration axonConfiguration) {
return axonConfiguration.repository(AccessorAggregateRoot.class);
}
}
@Component
public class AccessorCommandHandler implements IAggregateLoader<AccessorAggregateRoot, AccessorId> {
private Repository<AccessorAggregateRoot> accessorRepository;
private PasswordEncoder passwordEncoder;
@Autowired
public AccessorCommandHandler(
Repository<AccessorAggregateRoot> accessorAggregateRootRepository, PasswordEncoder passwordEncoder) {
this.accessorRepository = accessorAggregateRootRepository;
this.passwordEncoder = passwordEncoder;
}
}
but I’m getting the exception:
BeanCurrentlyInCreationException: Error creating bean with name ‘accessorAggregateRootRepository’: Requested bean is currently in creation: Is there an unresolvable circular reference?
If I remove the repository config from AccessorCommandConfiguration then it seems that repository is not configured, or maybe it’s configured after commandhandler