found an issue with @EnableAxonAutoConfiguration. For beans that have event handlers and use constructor injection with component scanning, an exception is thrown.
It is easy to reproduce. I created a spring boot app with jpa, web, hsqldb and lombok and then added the following code.
package com.example;
import org.axonframework.spring.config.EnableAxonAutoConfiguration;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
@ComponentScan
@EnableAxonAutoConfiguration
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
package com.example;
import org.springframework.stereotype.Component;
import javax.persistence.EntityManager;
@Component
public class SampleBean {
public SampleBean(EntityManager em) {
System.out.println("--->" + em);
}
//@EventHandler uncomment this to break app
public void on(String event) {
}
}
Uncommenting @EventHandler gives the following error
First off, thanks for the weminar. The trick using Kotlin for API definition is solving one of my major gripes I had.
I may have found another issue with the @EnableAxonAutoConfiguration. Ther appears to be some kind of interference with the useage of mongodb.
When I add the annotation to my configuration, MongoClient cannot longer be autowired. When I remove it, it works just fine, but I have to manually wire the command handlers for my aggregates.
Thanks a lot.
Dominic
Example:
@Configuration @EnableAxonAutoConfiguration
public class AxonConfiguration {
@Autowired
private MongoClient mongoClient;
@Bean
EventStorageEngine eventStorageEngine() {
return new MongoEventStorageEngine(new DefaultMongoTemplate(mongoClient));
I have managed to reproduce and fix issue. It will be part of the next release. Thanks for reporting it in detail.
The issue was with the timing at which the Axon component would wire things up. That was done a bit too early, so these components couldn’t be autowired yet.