Questions about Axon RC1

Hello everyone,

I am new in Axon. In my project using M5 I have the following code:

private Repository axonAccountRepository;

public AccountCommandHandlers(Repository axonAccountRepository) {
this.axonAccountRepository = axonAccountRepository;

axonAccountRepository.newInstance(() -> new Account(command.getAccountId(), etc, etc)

I am getting the following error:


Parameter 0 of constructor in com.norgay.accountservice.commandHandlers.AccountCommandHandlers required a bean of type ‘org.axonframework.commandhandling.model.Repository’ that could not be found.


Consider defining a bean of type ‘org.axonframework.commandhandling.model.Repository’ in your configuration.

What am I missing?

Hi Richard,

you may have more than one repository in your application context. In that case, Spring tries to inject one into the constructor. Apparantly, it didn’t find a suitable candidate. As far as I know, Spring resorts to named injection when there are multiple candidates. In your case, renaming the parameter to accountRepository may already help, as that’s the default name Axon gives it.

But even better, put your @CommandHandler annotations on the Aggregates themselves. That saves you from a lot of boilerplate code.
Check out the webinar series for a walk-through on how to do this:

In particular, these videos: