Property binding with Spring @Value annotation in an aggregate


I get inconsistent results when I use @Value inside an aggregate.
Is property binding using Spring @Value in an aggregate supported?

public class GiftCard {
private String appName;

public GiftCard(IssueCardCommand cmd) {
    **// this.appName is null here**

protected GiftCard() {
// omitted command handlers and event sourcing handlers



The lifecycle of aggregates isn’t managed by Spring, so unfortunately, you cannot use the @Value approach to injecting properties.
Axon provides an injection mechanism for handlers which you could use for this. Create a Spring bean that has the @Value annotated field, and then add that Spring bean as a parameter to your Command Handler (or any other handler that requires the property).

Hope this helps.


Thanks @allardbz!
That is exactly what I did.