There is org.springframework.boot.autoconfigure.domain.EntityScan and it should be used instead of org.axonframework.springboot.util.RegisterDefaultEntities.
These two annotations serve the same purpose - they specify packages with JPA entities.
@EntityScan also may define other entities, like NOSQL documents and natively integrates with Spring.
Do you mind elaborating why you see this issue as a necessity, @Sam-Kruglov?
1) Why duplicate this annotation if it already exists?
2) If I add my entity to @EntityScan, the spring preferred way, then packages, defined in Axon's JpaAutoConfiguration go away, and I have to include them manually. There may be similar conflicts the other way around when I use your annotation instead.
What I meant is updating the description of your issue, as it is ambiguous, but thank you for the up date regardless.
There is a significant difference between @EntityScan and the way Axon currently registers default. If Axon were to use @EntityScan, Spring Boot will no longer consider your own entities, unless you also explicitly declare them.
Axon follows the exact same principles: don鈥檛 declare anything, and you get defaults. As soon as you declare entities, the defaults no longer apply.
So regarding 1, it鈥檚 not the same annotation. The behavior is significantly different. Regarding 2, that is as designed.
Thanks, Allard! That makes sense. But I think there must be a way to append axon entities somehow internally, so that when a framework user wouldn't accidentally turn off those when declaring an @EntityScan. Or maybe highlight this in documentation that one should use @RegisterDefaultEntities instead when working with axon.
I view some explanation in the Reference Guide would cover this nicely.
Additionally, javadoc on the @RegisterDefaultEntities would alleviate future occurrences of similar suggestions like this, I'd assume.
For now, I will be closing this issue, taking the Reference Guide solution is the way to go.
Additionally, thanks for filing this @Sam-Kruglov, hope things have become clearer now!
Hi Steven @smcvb or those who know,
Unfortunately, I can't see any guide/example on how to use RegisterDefaultEntities (whether with EntityScan, or without it). JavaDoc of RegisterDefaultEntities doesn't even say what object/bean to use it on, and what its parameter packages is. Please advise.
@peter-kehl use github code search whenever in doubt https://github.com/search?type=Code&q=%22%40RegisterDefaultEntities%22