Axon not scanning dependency library

Hallo,

We using axon 3.0.7 with spring boot 1.5.7.RELEASE and every thing was working correctly until we decided to put all our domain logic in a separate package that can be referenced by multiples projects without rewriting the code e.g events, command and aggregates. everything compiles and runs but we now getting:

org.axonframework.commandhandling.NoHandlerForCommandException: No handler was subscribed to command

Greatly appreciate help on this.

Regards

Hi Anthony,

you probably moved the Aggregates (and other beans) out of the scope of the package that contains the Application class.

See https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-structuring-your-code.html

Cheers,

Allard

Anthony’s approach to having separate packages seems reasonable and normally in Spring you can add basePackages to component scans so that Spring will find them. Is that not the case with Axon? i.e. if one adds the separate package name to Spring’s scanning config i.e.

@SpringBootApplication(scanBasedPackages= {“myapppackage”, “myseparatepackage”})

will Axon be able to find what it needs in “myseparatepackage”?

Hi,

Axon doesn’t do any classpath scanning itself. When using it in combination with Spring, it uses the application context to autoconfigure its components. So if Spring finds it, Axon will use it. And yes, setting base packages for your Spring Boot application will definitely work.

Cheers,

Allard

Okay, thanks for the info.